[1761] | 1 | #ifndef __SERVERS_RESSOURCE_HPP__ |
---|
| 2 | #define __SERVERS_RESSOURCE_HPP__ |
---|
| 3 | |
---|
| 4 | #include "window_manager.hpp" |
---|
[2523] | 5 | #include "event_scheduler.hpp" |
---|
[1761] | 6 | #include "mpi.hpp" |
---|
| 7 | #include <vector> |
---|
| 8 | #include <string> |
---|
| 9 | |
---|
| 10 | |
---|
| 11 | |
---|
| 12 | namespace xios |
---|
| 13 | { |
---|
| 14 | |
---|
| 15 | class CPoolRessource ; |
---|
| 16 | |
---|
| 17 | class CServersRessource |
---|
| 18 | { |
---|
| 19 | |
---|
| 20 | const int NOTIFY_NOTHING=0 ; |
---|
| 21 | const int NOTIFY_CREATE_POOL=1 ; |
---|
| 22 | const int NOTIFY_FINALIZE=2 ; |
---|
| 23 | |
---|
| 24 | public: |
---|
| 25 | |
---|
| 26 | CServersRessource(MPI_Comm serverComm) ; |
---|
[2274] | 27 | ~CServersRessource() ; |
---|
[1761] | 28 | void createPool(const string& poolId, const int size) ; |
---|
| 29 | void createPool(void) ; |
---|
[1764] | 30 | bool eventLoop(bool serviceOnly=false) ; |
---|
[1761] | 31 | void sendNotification(int rank) ; |
---|
| 32 | void notificationsDumpOut(CBufferOut& buffer) ; |
---|
| 33 | void notificationsDumpIn(CBufferIn& buffer) ; |
---|
| 34 | void checkNotifications(void) ; |
---|
| 35 | CPoolRessource* getPoolRessource(void) { return poolRessource_; } |
---|
[2523] | 36 | const MPI_Comm& getCommunicator(void) { return serverComm_ ;} |
---|
[1761] | 37 | bool isServerLeader(void) ; |
---|
| 38 | void finalize(void) ; |
---|
| 39 | void finalizeSignal(void) ; |
---|
| 40 | |
---|
| 41 | const int localLeader_=0 ; |
---|
| 42 | vector<int> freeRessourcesRank_ ; // only for leader |
---|
| 43 | MPI_Comm serverComm_ ; |
---|
| 44 | MPI_Comm freeRessourcesComm_ ; |
---|
| 45 | |
---|
| 46 | |
---|
| 47 | const size_t maxBufferSize_=1024*1024 ; |
---|
| 48 | CWindowManager* winNotify_ ; |
---|
[1764] | 49 | |
---|
| 50 | int notifyInType_,notifyOutType_ ; |
---|
| 51 | std::tuple<std::string, bool> notifyInCreatePool_,notifyOutCreatePool_ ; |
---|
[1761] | 52 | CPoolRessource* poolRessource_ ; |
---|
| 53 | bool finalizeSignal_ ; |
---|
| 54 | |
---|
[2260] | 55 | const double eventLoopLatency_=0; |
---|
[2246] | 56 | double lastEventLoop_=0. ; |
---|
[2547] | 57 | |
---|
[2523] | 58 | private: |
---|
[2547] | 59 | bool finished_=false; |
---|
| 60 | public: |
---|
| 61 | bool isFinished(void) { return finished_ ;} |
---|
| 62 | private: |
---|
| 63 | void synchronize(void) ; |
---|
| 64 | void threadEventLoop(void) ; |
---|
[2523] | 65 | shared_ptr<CEventScheduler> eventScheduler_ ; |
---|
| 66 | shared_ptr<CEventScheduler> freeRessourceEventScheduler_ ; |
---|
| 67 | bool isFirstSplit_=true ; |
---|
| 68 | public: |
---|
| 69 | shared_ptr<CEventScheduler> getEventScheduler(void) { return eventScheduler_ ;} |
---|
[1761] | 70 | friend class CWindowManager ; |
---|
| 71 | } ; |
---|
| 72 | |
---|
| 73 | } |
---|
| 74 | |
---|
| 75 | |
---|
| 76 | |
---|
| 77 | #endif |
---|