[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 | { |
---|
[2266] | 34 | finalize() ; |
---|
[1764] | 35 | } |
---|
| 36 | |
---|
[1761] | 37 | bool CDaemonsManager::eventLoop(void) |
---|
| 38 | { |
---|
[2246] | 39 | |
---|
[1761] | 40 | CXios::getRessourcesManager()->eventLoop() ; |
---|
| 41 | CXios::getServicesManager()->eventLoop() ; |
---|
| 42 | CXios::getContextsManager()->eventLoop() ; |
---|
[1764] | 43 | if (isServer_) return CServer::getServersRessource()->eventLoop(false) ; |
---|
| 44 | else return CXios::getPoolRessource()->eventLoop(false) ; |
---|
[1761] | 45 | } |
---|
[1764] | 46 | |
---|
| 47 | bool CDaemonsManager::servicesEventLoop(void) |
---|
| 48 | { |
---|
| 49 | CXios::getRessourcesManager()->eventLoop() ; |
---|
| 50 | CXios::getServicesManager()->eventLoop() ; |
---|
| 51 | CXios::getContextsManager()->eventLoop() ; |
---|
| 52 | if (isServer_) return CServer::getServersRessource()->eventLoop(true) ; |
---|
| 53 | else return CXios::getPoolRessource()->eventLoop(true) ; |
---|
| 54 | } |
---|
[1761] | 55 | |
---|
[2266] | 56 | bool CDaemonsManager::finalize(void) |
---|
| 57 | { |
---|
| 58 | if (!isFinalized_) |
---|
| 59 | { |
---|
| 60 | if (isServer_) CServer::getServersRessource()->finalizeSignal() ; |
---|
| 61 | else CXios::getPoolRessource()->finalizeSignal() ; |
---|
| 62 | while(!eventLoop()) ; |
---|
| 63 | MPI_Barrier( CXios::getXiosComm()) ; |
---|
| 64 | CXios::finalizeContextsManager() ; |
---|
| 65 | CXios::finalizeCouplerManager() ; |
---|
| 66 | CXios::finalizeServicesManager() ; |
---|
| 67 | CXios::finalizeRessourcesManager() ; |
---|
| 68 | CXios::finalizeRegistryManager() ; |
---|
| 69 | isFinalized_=true ; |
---|
| 70 | } |
---|
[2277] | 71 | return isFinalized_; |
---|
[2266] | 72 | } |
---|
| 73 | |
---|
[2277] | 74 | } |
---|