source: XIOS/dev/dev_ym/XIOS_COUPLING/src/manager/daemons_manager.cpp @ 2277

Last change on this file since 2277 was 2277, checked in by jderouillat, 2 years ago

Bug fix for recent version of GCC, see commits 1852/2196

  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 2.1 KB
Line 
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
9namespace 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_) return CServer::getServersRessource()->eventLoop(false) ;
44    else  return CXios::getPoolRessource()->eventLoop(false) ;
45  }
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  } 
55
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    }
71    return isFinalized_;
72  }
73
74}
Note: See TracBrowser for help on using the repository browser.