[1761] | 1 | #ifndef __RESSOURCES_MANAGER_HPP__ |
---|
| 2 | #define __RESSOURCES_MANAGER_HPP__ |
---|
| 3 | |
---|
| 4 | #include "xios_spl.hpp" |
---|
| 5 | #include "mpi.hpp" |
---|
| 6 | #include "buffer_in.hpp" |
---|
| 7 | #include "buffer_out.hpp" |
---|
| 8 | |
---|
| 9 | #include <string> |
---|
| 10 | #include <map> |
---|
| 11 | #include "window_manager.hpp" |
---|
| 12 | #include "pool_ressource.hpp" |
---|
[2455] | 13 | #include "token_manager.hpp" |
---|
[1761] | 14 | |
---|
| 15 | |
---|
| 16 | |
---|
| 17 | namespace xios |
---|
| 18 | { |
---|
| 19 | |
---|
| 20 | |
---|
| 21 | class CRessourcesManager |
---|
| 22 | { |
---|
| 23 | |
---|
| 24 | const int NOTIFY_NOTHING=0 ; |
---|
| 25 | const int NOTIFY_CREATE_POOL=1 ; |
---|
| 26 | const int NOTIFY_FINALIZE=2 ; |
---|
| 27 | |
---|
| 28 | public: |
---|
| 29 | |
---|
| 30 | CRessourcesManager(bool isXiosServer) ; |
---|
[1764] | 31 | ~CRessourcesManager() ; |
---|
[1761] | 32 | |
---|
| 33 | void eventLoop(void) ; |
---|
| 34 | void createPool(const std::string& id, int size) ; |
---|
| 35 | void createPool(void) ; |
---|
| 36 | void finalize(void) ; |
---|
| 37 | void finalizeSignal(void) ; |
---|
| 38 | void sendNotification(int rank); |
---|
| 39 | void checkNotifications(void) ; |
---|
| 40 | void notificationsDumpOut(CBufferOut& buffer) ; |
---|
| 41 | void notificationsDumpIn(CBufferIn& buffer) ; |
---|
| 42 | |
---|
| 43 | void ressourcesDumpOut(CBufferOut& buffer) ; |
---|
| 44 | void ressourcesDumpIn(CBufferIn& buffer) ; |
---|
| 45 | |
---|
| 46 | int getRessourcesSize(void) ; |
---|
| 47 | int getFreeRessourcesSize(void) ; |
---|
[2453] | 48 | bool getPoolInfo(const string& poolId, int& size, int& freeSize, int& leader) ; |
---|
[1761] | 49 | bool getPoolLeader(const string& poolId, int& leader) ; |
---|
| 50 | bool getPoolSize(const string& poolId, int& size) ; |
---|
[2453] | 51 | bool getPoolFreeSize(const string& poolId, int& freeSize) ; |
---|
[1761] | 52 | bool hasPool(const string& poolId) ; |
---|
[2453] | 53 | bool decreasePoolFreeSize(const string& poolId, int size) ; |
---|
| 54 | void waitPoolRegistration(const string& poolId) ; |
---|
| 55 | |
---|
[2455] | 56 | |
---|
[1761] | 57 | void registerServerLeader(int leaderRank) ; |
---|
| 58 | void registerRessourcesSize(int size) ; |
---|
[2453] | 59 | void registerPoolClient(const std::string& poolId,int size,int leader) ; |
---|
| 60 | void registerPoolServer(const std::string& poolId,int size,int leader) ; |
---|
[2455] | 61 | CTokenManager* getTokenManager(void) {return tokenManager_ ;} |
---|
[1761] | 62 | |
---|
| 63 | int managerGlobalLeader_ ; |
---|
| 64 | |
---|
| 65 | CWindowManager* winRessources_ ; |
---|
| 66 | |
---|
| 67 | CWindowManager* winNotify_ ; |
---|
[2455] | 68 | CTokenManager* tokenManager_ ; |
---|
[1761] | 69 | |
---|
| 70 | const size_t maxBufferSize_=1024*1024 ; |
---|
| 71 | |
---|
| 72 | MPI_Comm xiosComm_ ; |
---|
| 73 | |
---|
| 74 | int notifyType_ ; |
---|
| 75 | tuple<std::string, int> notifyCreatePool_ ; |
---|
| 76 | |
---|
[2453] | 77 | std::map<std::string, std::tuple<int,int,int>> pools_ ; |
---|
[1761] | 78 | int serverLeader_ ; |
---|
| 79 | int ressourcesSize_ ; |
---|
| 80 | int freeRessourcesSize_ ; |
---|
| 81 | |
---|
[2260] | 82 | const double eventLoopLatency_=0; |
---|
[2246] | 83 | double lastEventLoop_=0. ; |
---|
| 84 | |
---|
[1761] | 85 | friend class CWindowManager ; |
---|
| 86 | } ; |
---|
| 87 | |
---|
| 88 | } |
---|
[2453] | 89 | #endif |
---|