[1761] | 1 | #ifndef __POOL_RESSOURCE_HPP__ |
---|
| 2 | #define __POOL_RESSOURCE_HPP__ |
---|
| 3 | |
---|
| 4 | #include "mpi.hpp" |
---|
| 5 | #include "window_manager.hpp" |
---|
| 6 | #include "services_manager.hpp" |
---|
| 7 | |
---|
| 8 | |
---|
| 9 | namespace xios |
---|
| 10 | { |
---|
| 11 | |
---|
| 12 | class CService ; |
---|
| 13 | |
---|
| 14 | class CPoolRessource |
---|
| 15 | { |
---|
| 16 | private: |
---|
| 17 | |
---|
| 18 | const size_t maxBufferSize_=1024*1024 ; |
---|
| 19 | const int localLeader_ = 0 ; |
---|
| 20 | |
---|
| 21 | CWindowManager* winNotify_ ; |
---|
| 22 | |
---|
[2404] | 23 | private: |
---|
| 24 | const int NOTIFY_NOTHING=0 ; |
---|
| 25 | const int NOTIFY_CREATE_SERVICE=1 ; |
---|
| 26 | const int NOTIFY_CREATE_SERVICE_ONTO=2 ; |
---|
| 27 | |
---|
| 28 | public: |
---|
[1761] | 29 | CPoolRessource(MPI_Comm poolComm, const std::string& Id) ; |
---|
[2274] | 30 | ~CPoolRessource() ; |
---|
[1761] | 31 | |
---|
| 32 | void createService(const std::string& serviceId, int type, int size, int nbPartition) ; |
---|
| 33 | void createService(MPI_Comm serviceComm, const std::string& serviceId, int partitionId, int type, int nbPartitions) ; |
---|
[2404] | 34 | void createServiceOnto(const std::string& serviceId, int type, const std::string& OnServiceId) ; |
---|
| 35 | bool eventLoop(bool serviceOnly=false) ; |
---|
[1761] | 36 | CService* getService(const std::string serviceId, int partitionId) { return services_[make_tuple(serviceId,partitionId)]; } |
---|
| 37 | void finalizeSignal(void) ; |
---|
| 38 | string getId(void) { return Id_; } |
---|
[2404] | 39 | |
---|
| 40 | private: |
---|
| 41 | void createServiceNotify(int rank, const string& serviceId, int type, int size, int nbPartitions, bool in) ; |
---|
| 42 | void createServiceOntoNotify(int rank, const string& serviceId, int type, const string& onServiceId) ; |
---|
| 43 | void sendNotification(int rank) ; |
---|
| 44 | void checkNotifications(void) ; |
---|
| 45 | void notificationsDumpOut(CBufferOut& buffer) ; |
---|
| 46 | void notificationsDumpIn(CBufferIn& buffer) ; |
---|
| 47 | void createService(void) ; |
---|
| 48 | void createServiceOnto(void) ; |
---|
[1761] | 49 | |
---|
[2404] | 50 | // void createServiceNotify(int rank, const std::string& serviceId, int type, int size, int nbPartitions, bool in) ; |
---|
| 51 | // void createServiceDumpOut(CBufferOut& buffer) ; |
---|
| 52 | // void createServiceDumpIn(CBufferIn& buffer) ; |
---|
| 53 | // void checkCreateServiceNotification(void) ; |
---|
| 54 | void createNewService(const std::string& serviceId, int type, int size, int nbPartitions, bool in) ; |
---|
| 55 | void createNewServiceOnto(const std::string& serviceId, int type, const string& onServiceId) ; |
---|
| 56 | |
---|
| 57 | private: |
---|
[1761] | 58 | MPI_Comm poolComm_ ; |
---|
| 59 | |
---|
| 60 | std::multimap<int,int> occupancy_ ; |
---|
[2404] | 61 | |
---|
| 62 | // std::list<std::tuple<std::string, int, int, int, bool> > notifications_; |
---|
| 63 | |
---|
| 64 | int notifyType_ ; |
---|
| 65 | tuple<std::string, int, int, int, bool> notifyCreateService_ ; |
---|
| 66 | tuple<std::string, int, std::string> notifyCreateServiceOnto_ ; |
---|
| 67 | |
---|
| 68 | |
---|
[1761] | 69 | std::map< std::tuple<std::string, int>, CService*> services_ ; |
---|
| 70 | std::string Id_ ; |
---|
| 71 | bool finalizeSignal_ ; |
---|
[2246] | 72 | |
---|
[2260] | 73 | const double eventLoopLatency_=0; |
---|
[2246] | 74 | double lastEventLoop_=0. ; |
---|
[1761] | 75 | }; |
---|
| 76 | |
---|
| 77 | } |
---|
| 78 | |
---|
| 79 | |
---|
| 80 | |
---|
| 81 | #endif |
---|