[1761] | 1 | #ifndef __SERVICE_HPP__ |
---|
| 2 | #define __SERVICE_HPP__ |
---|
| 3 | |
---|
| 4 | #include "xios_spl.hpp" |
---|
| 5 | #include "mpi.hpp" |
---|
| 6 | #include "services_manager.hpp" |
---|
| 7 | #include "event_scheduler.hpp" |
---|
| 8 | |
---|
| 9 | namespace xios |
---|
| 10 | { |
---|
| 11 | |
---|
| 12 | class CServerContext ; |
---|
| 13 | |
---|
| 14 | class CService |
---|
| 15 | { |
---|
| 16 | public: |
---|
| 17 | |
---|
[1764] | 18 | const int NOTIFY_NOTHING=0 ; |
---|
| 19 | const int NOTIFY_CREATE_CONTEXT=1 ; |
---|
| 20 | |
---|
[1761] | 21 | CService(MPI_Comm serviceComm, const std::string& poolId, const std::string& serviceId, const int& partitionId, |
---|
| 22 | int type, int nbPartitions) ; |
---|
[2274] | 23 | ~CService() ; |
---|
| 24 | |
---|
[1764] | 25 | bool eventLoop(bool serviceOnly=false) ; |
---|
[1761] | 26 | void createContext(const std::string& poolId, const std::string& serviceId, const int& partitionId, const std::string& contextId) ; |
---|
| 27 | void checkCreateContextNotification(void) ; |
---|
| 28 | void createContextNotify(int rank, const std::string& poolId, const std::string& serviceId, const int& partitionId, const std::string& contextId) ; |
---|
| 29 | void createContextDumpOut(CBufferOut& buffer) ; |
---|
| 30 | void createContextDumpIn(CBufferIn& buffer) ; |
---|
| 31 | void createNewContext(const std::string& poolId, const std::string& serviceId, const int& partitionId, const std::string& contextId) ; |
---|
| 32 | CServerContext* getServerContext(const std::string& contextId) { return contexts_[contextId]; } |
---|
| 33 | void finalizeSignal(void) ; |
---|
| 34 | CEventScheduler* getEventScheduler(void) ; |
---|
| 35 | |
---|
| 36 | std::string getPoolId(void) {return poolId_;} |
---|
| 37 | std::string getServiceId(void) {return serviceId_;} |
---|
| 38 | int getPartitionId(void) {return partitionId_;} |
---|
| 39 | int getType(void) {return type_;} |
---|
| 40 | int getNbPartitions(void) {return nbPartitions_;} |
---|
[2130] | 41 | |
---|
[1761] | 42 | private: |
---|
[1764] | 43 | void sendNotification(int rank) ; |
---|
| 44 | void notificationsDumpOut(CBufferOut& buffer) ; |
---|
| 45 | void notificationsDumpIn(CBufferIn& buffer) ; |
---|
| 46 | void checkNotifications(void) ; |
---|
| 47 | void createContext(void) ; |
---|
| 48 | |
---|
[1761] | 49 | MPI_Comm serviceComm_ ; |
---|
| 50 | MPI_Comm globalComm_ ; |
---|
[1764] | 51 | |
---|
[1761] | 52 | const size_t maxBufferSize_=1024*1024 ; |
---|
| 53 | const int localLeader_=0 ; |
---|
| 54 | int globalLeader_ ; |
---|
| 55 | CWindowManager* winNotify_ ; |
---|
[1764] | 56 | |
---|
| 57 | std::string name_ ; |
---|
| 58 | |
---|
[1761] | 59 | std::list<std::tuple<std::string, std::string, int, std::string>> notifications_; |
---|
[1764] | 60 | |
---|
| 61 | bool hasNotification_ ; |
---|
| 62 | int notifyInType_,notifyOutType_ ; |
---|
| 63 | std::tuple<std::string, std::string, int, std::string> notifyInCreateContext_, notifyOutCreateContext_ ; |
---|
| 64 | |
---|
[1761] | 65 | std::map<std::string, CServerContext*> contexts_ ; |
---|
| 66 | bool finalizeSignal_ ; |
---|
| 67 | CEventScheduler* eventScheduler_ ; |
---|
| 68 | |
---|
| 69 | std::string poolId_ ; |
---|
| 70 | std::string serviceId_ ; |
---|
| 71 | int partitionId_ ; |
---|
| 72 | int type_ ; |
---|
| 73 | int nbPartitions_ ; |
---|
| 74 | |
---|
[2260] | 75 | const double eventLoopLatency_=0; |
---|
[2246] | 76 | double lastEventLoop_=0. ; |
---|
| 77 | |
---|
[1761] | 78 | }; |
---|
| 79 | |
---|
| 80 | } |
---|
| 81 | |
---|
| 82 | |
---|
| 83 | |
---|
| 84 | #endif |
---|