[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, |
---|
[2404] | 22 | int type, int nbPartitions, shared_ptr<CEventScheduler> = nullptr) ; |
---|
[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) ; |
---|
[2404] | 34 | shared_ptr<CEventScheduler> getEventScheduler(void) ; |
---|
[1761] | 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_;} |
---|
[2404] | 41 | const MPI_Comm& getCommunicator(void) { return serviceComm_ ;} |
---|
[2130] | 42 | |
---|
[1761] | 43 | private: |
---|
[1764] | 44 | void sendNotification(int rank) ; |
---|
| 45 | void notificationsDumpOut(CBufferOut& buffer) ; |
---|
| 46 | void notificationsDumpIn(CBufferIn& buffer) ; |
---|
| 47 | void checkNotifications(void) ; |
---|
| 48 | void createContext(void) ; |
---|
| 49 | |
---|
[1761] | 50 | MPI_Comm serviceComm_ ; |
---|
| 51 | MPI_Comm globalComm_ ; |
---|
[1764] | 52 | |
---|
[1761] | 53 | const size_t maxBufferSize_=1024*1024 ; |
---|
| 54 | const int localLeader_=0 ; |
---|
| 55 | int globalLeader_ ; |
---|
| 56 | CWindowManager* winNotify_ ; |
---|
[1764] | 57 | |
---|
| 58 | std::string name_ ; |
---|
| 59 | |
---|
[1761] | 60 | std::list<std::tuple<std::string, std::string, int, std::string>> notifications_; |
---|
[1764] | 61 | |
---|
| 62 | bool hasNotification_ ; |
---|
| 63 | int notifyInType_,notifyOutType_ ; |
---|
| 64 | std::tuple<std::string, std::string, int, std::string> notifyInCreateContext_, notifyOutCreateContext_ ; |
---|
| 65 | |
---|
[1761] | 66 | std::map<std::string, CServerContext*> contexts_ ; |
---|
| 67 | bool finalizeSignal_ ; |
---|
[2404] | 68 | shared_ptr<CEventScheduler> eventScheduler_ ; |
---|
[1761] | 69 | |
---|
| 70 | std::string poolId_ ; |
---|
| 71 | std::string serviceId_ ; |
---|
| 72 | int partitionId_ ; |
---|
| 73 | int type_ ; |
---|
| 74 | int nbPartitions_ ; |
---|
| 75 | |
---|
[2260] | 76 | const double eventLoopLatency_=0; |
---|
[2246] | 77 | double lastEventLoop_=0. ; |
---|
| 78 | |
---|
[1761] | 79 | }; |
---|
| 80 | |
---|
| 81 | } |
---|
| 82 | |
---|
| 83 | |
---|
| 84 | |
---|
| 85 | #endif |
---|