[1761] | 1 | #include "daemons_manager.hpp" |
---|
| 2 | #include "cxios.hpp" |
---|
| 3 | #include "ressources_manager.hpp" |
---|
| 4 | #include "services_manager.hpp" |
---|
| 5 | #include "contexts_manager.hpp" |
---|
| 6 | #include "servers_ressource.hpp" |
---|
| 7 | #include "server.hpp" |
---|
| 8 | |
---|
| 9 | namespace xios |
---|
| 10 | { |
---|
| 11 | using namespace std ; |
---|
| 12 | |
---|
| 13 | CDaemonsManager::CDaemonsManager(bool isXiosServer) : isServer_(isXiosServer) |
---|
| 14 | { |
---|
| 15 | MPI_Comm xiosComm = CXios::getXiosComm() ; |
---|
| 16 | int commRank ; |
---|
| 17 | MPI_Comm_rank(xiosComm,&commRank) ; |
---|
| 18 | MPI_Comm splitComm ; |
---|
| 19 | MPI_Comm_split(xiosComm,isXiosServer,commRank,&splitComm) ; |
---|
| 20 | |
---|
[2209] | 21 | CXios::launchRegistryManager(isXiosServer) ; |
---|
[1761] | 22 | CXios::launchRessourcesManager(isXiosServer) ; |
---|
| 23 | CXios::launchServicesManager(isXiosServer) ; |
---|
| 24 | CXios::launchContextsManager(isXiosServer) ; |
---|
[1878] | 25 | CXios::launchCouplerManager(isXiosServer) ; |
---|
[2209] | 26 | |
---|
[1761] | 27 | if (isXiosServer) CServer::launchServersRessource(splitComm) ; |
---|
[2209] | 28 | MPI_Barrier(xiosComm) ; |
---|
[1761] | 29 | MPI_Comm_free(&splitComm) ; |
---|
| 30 | } |
---|
| 31 | |
---|
[1764] | 32 | CDaemonsManager::~CDaemonsManager() |
---|
| 33 | { |
---|
| 34 | CXios::finalizeContextsManager() ; |
---|
[1878] | 35 | CXios::finalizeCouplerManager() ; |
---|
[1764] | 36 | CXios::finalizeServicesManager() ; |
---|
| 37 | CXios::finalizeRessourcesManager() ; |
---|
[2209] | 38 | CXios::finalizeRegistryManager() ; |
---|
[1764] | 39 | } |
---|
| 40 | |
---|
[1761] | 41 | bool CDaemonsManager::eventLoop(void) |
---|
| 42 | { |
---|
| 43 | CXios::getRessourcesManager()->eventLoop() ; |
---|
| 44 | CXios::getServicesManager()->eventLoop() ; |
---|
| 45 | CXios::getContextsManager()->eventLoop() ; |
---|
[1764] | 46 | if (isServer_) return CServer::getServersRessource()->eventLoop(false) ; |
---|
| 47 | else return CXios::getPoolRessource()->eventLoop(false) ; |
---|
[1761] | 48 | } |
---|
[1764] | 49 | |
---|
| 50 | bool CDaemonsManager::servicesEventLoop(void) |
---|
| 51 | { |
---|
| 52 | CXios::getRessourcesManager()->eventLoop() ; |
---|
| 53 | CXios::getServicesManager()->eventLoop() ; |
---|
| 54 | CXios::getContextsManager()->eventLoop() ; |
---|
| 55 | if (isServer_) return CServer::getServersRessource()->eventLoop(true) ; |
---|
| 56 | else return CXios::getPoolRessource()->eventLoop(true) ; |
---|
| 57 | } |
---|
[1761] | 58 | |
---|
| 59 | } |
---|