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 | |
---|
21 | CXios::launchRegistryManager(isXiosServer) ; |
---|
22 | CXios::launchRessourcesManager(isXiosServer) ; |
---|
23 | CXios::launchServicesManager(isXiosServer) ; |
---|
24 | CXios::launchContextsManager(isXiosServer) ; |
---|
25 | CXios::launchCouplerManager(isXiosServer) ; |
---|
26 | |
---|
27 | if (isXiosServer) CServer::launchServersRessource(splitComm) ; |
---|
28 | MPI_Barrier(xiosComm) ; |
---|
29 | MPI_Comm_free(&splitComm) ; |
---|
30 | } |
---|
31 | |
---|
32 | CDaemonsManager::~CDaemonsManager() |
---|
33 | { |
---|
34 | finalize() ; |
---|
35 | } |
---|
36 | |
---|
37 | bool CDaemonsManager::eventLoop(void) |
---|
38 | { |
---|
39 | |
---|
40 | CXios::getRessourcesManager()->eventLoop() ; |
---|
41 | CXios::getServicesManager()->eventLoop() ; |
---|
42 | CXios::getContextsManager()->eventLoop() ; |
---|
43 | if (isServer_) { |
---|
44 | if (CServer::isRoot) { |
---|
45 | CServer::listenOasisEnddef() ; |
---|
46 | CServer::listenRootOasisEnddef() ; |
---|
47 | } |
---|
48 | else { |
---|
49 | CServer::listenRootOasisEnddef() ; |
---|
50 | } |
---|
51 | return CServer::getServersRessource()->eventLoop(false) ; |
---|
52 | } |
---|
53 | else return CXios::getPoolRessource()->eventLoop(false) ; |
---|
54 | } |
---|
55 | |
---|
56 | bool CDaemonsManager::servicesEventLoop(void) |
---|
57 | { |
---|
58 | CXios::getRessourcesManager()->eventLoop() ; |
---|
59 | CXios::getServicesManager()->eventLoop() ; |
---|
60 | CXios::getContextsManager()->eventLoop() ; |
---|
61 | if (isServer_) return CServer::getServersRessource()->eventLoop(true) ; |
---|
62 | else return CXios::getPoolRessource()->eventLoop(true) ; |
---|
63 | } |
---|
64 | |
---|
65 | bool CDaemonsManager::finalize(void) |
---|
66 | { |
---|
67 | if (!isFinalized_) |
---|
68 | { |
---|
69 | if (isServer_) CServer::getServersRessource()->finalizeSignal() ; |
---|
70 | else CXios::getPoolRessource()->finalizeSignal() ; |
---|
71 | while(!eventLoop()) ; |
---|
72 | MPI_Barrier( CXios::getXiosComm()) ; |
---|
73 | CXios::finalizeContextsManager() ; |
---|
74 | CXios::finalizeCouplerManager() ; |
---|
75 | CXios::finalizeServicesManager() ; |
---|
76 | CXios::finalizeRessourcesManager() ; |
---|
77 | CXios::finalizeRegistryManager() ; |
---|
78 | isFinalized_=true ; |
---|
79 | } |
---|
80 | return isFinalized_; |
---|
81 | } |
---|
82 | |
---|
83 | } |
---|