source: XIOS/dev/dev_ym/XIOS_COUPLING/src/manager/services.hpp @ 2274

Last change on this file since 2274 was 2274, checked in by ymipsl, 3 years ago

Tracking memory leak : release memory statically alocated

YM

  • Property svn:executable set to *
File size: 2.6 KB
Line 
1#ifndef __SERVICE_HPP__
2#define __SERVICE_HPP__
3
4#include "xios_spl.hpp"
5#include "mpi.hpp"
6#include "services_manager.hpp"
7#include "event_scheduler.hpp"
8
9namespace xios
10{
11
12  class CServerContext ;
13
14  class CService
15  {
16    public:
17   
18    const int NOTIFY_NOTHING=0 ;
19    const int NOTIFY_CREATE_CONTEXT=1 ;
20
21    CService(MPI_Comm serviceComm, const std::string& poolId, const std::string& serviceId, const int& partitionId, 
22             int type, int nbPartitions) ;
23    ~CService() ;
24
25    bool eventLoop(bool serviceOnly=false) ;
26    void createContext(const std::string& poolId, const std::string& serviceId, const int& partitionId, const std::string& contextId) ;
27    void checkCreateContextNotification(void) ;
28    void createContextNotify(int rank, const std::string& poolId, const std::string& serviceId, const int& partitionId, const std::string& contextId) ;
29    void createContextDumpOut(CBufferOut& buffer) ;
30    void createContextDumpIn(CBufferIn& buffer) ;
31    void createNewContext(const std::string& poolId, const std::string& serviceId, const int& partitionId, const std::string& contextId) ;
32    CServerContext* getServerContext(const std::string& contextId) { return contexts_[contextId]; }
33    void finalizeSignal(void) ;
34    CEventScheduler* getEventScheduler(void) ;
35
36    std::string getPoolId(void) {return poolId_;}
37    std::string getServiceId(void) {return serviceId_;}
38    int getPartitionId(void) {return partitionId_;}
39    int getType(void) {return type_;}
40    int getNbPartitions(void) {return nbPartitions_;}
41   
42    private:
43    void sendNotification(int rank) ;
44    void notificationsDumpOut(CBufferOut& buffer) ;
45    void notificationsDumpIn(CBufferIn& buffer) ;
46    void checkNotifications(void) ;
47    void createContext(void) ;
48
49    MPI_Comm serviceComm_ ;
50    MPI_Comm globalComm_ ;
51
52    const size_t maxBufferSize_=1024*1024 ;
53    const int localLeader_=0 ;
54    int globalLeader_ ;
55    CWindowManager* winNotify_ ;
56   
57    std::string name_ ;
58
59    std::list<std::tuple<std::string, std::string, int, std::string>> notifications_;
60   
61    bool hasNotification_ ;
62    int notifyInType_,notifyOutType_ ;
63    std::tuple<std::string, std::string, int, std::string> notifyInCreateContext_, notifyOutCreateContext_ ;
64
65    std::map<std::string, CServerContext*> contexts_ ;
66    bool finalizeSignal_ ;
67    CEventScheduler* eventScheduler_ ;
68
69    std::string poolId_ ;
70    std::string serviceId_ ;
71    int partitionId_ ;
72    int type_ ;
73    int nbPartitions_ ;
74
75    const double eventLoopLatency_=0; 
76    double lastEventLoop_=0. ;
77
78  };
79
80}
81
82
83
84#endif
Note: See TracBrowser for help on using the repository browser.