source: XIOS3/trunk/src/manager/services.hpp @ 2547

Last change on this file since 2547 was 2547, checked in by ymipsl, 10 months ago

Major update :

  • New method to lock and unlock one-sided windows (window_dynamic) to avoid network overhead
  • Introducing multithreading on server sided to manage more efficiently dead-lock occuring (similar to co-routine which will be available and implemented in futur c++ standard), based on c++ threads
  • Suprression of old "attached mode" which is replaced by online writer and reder filters

YM

  • Property svn:executable set to *
File size: 2.9 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, shared_ptr<CEventScheduler>, 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 threadEventLoop(void) ;
27    void createContext(const std::string& poolId, const std::string& serviceId, const int& partitionId, const std::string& contextId) ;
28    void checkCreateContextNotification(void) ;
29    void createContextNotify(int rank, const std::string& poolId, const std::string& serviceId, const int& partitionId, const std::string& contextId) ;
30    void createContextDumpOut(CBufferOut& buffer) ;
31    void createContextDumpIn(CBufferIn& buffer) ;
32    void createNewContext(const std::string& poolId, const std::string& serviceId, const int& partitionId, const std::string& contextId) ;
33    CServerContext* getServerContext(const std::string& contextId) { return contexts_[contextId]; }
34    void finalizeSignal(void) ;
35    shared_ptr<CEventScheduler> getEventScheduler(void) ;
36
37    std::string getPoolId(void) {return poolId_;}
38    std::string getServiceId(void) {return serviceId_;}
39    int getPartitionId(void) {return partitionId_;}
40    int getType(void) {return type_;}
41    int getNbPartitions(void) {return nbPartitions_;}
42    const MPI_Comm& getCommunicator(void) { return serviceComm_ ;}
43   
44    private: 
45    bool finished_=false ;
46    public:
47    bool isFinished(void) { return finished_; }
48
49    private:
50    void sendNotification(int rank) ;
51    void notificationsDumpOut(CBufferOut& buffer) ;
52    void notificationsDumpIn(CBufferIn& buffer) ;
53    void checkNotifications(void) ;
54    void createContext(void) ;
55
56    MPI_Comm serviceComm_ ;
57    MPI_Comm globalComm_ ;
58
59    const size_t maxBufferSize_=1024*1024 ;
60    const int localLeader_=0 ;
61    int globalLeader_ ;
62    CWindowManager* winNotify_ ;
63   
64    std::string name_ ;
65
66    std::list<std::tuple<std::string, std::string, int, std::string>> notifications_;
67   
68    bool hasNotification_ ;
69    int notifyInType_,notifyOutType_ ;
70    std::tuple<std::string, std::string, int, std::string> notifyInCreateContext_, notifyOutCreateContext_ ;
71
72    std::map<std::string, CServerContext*> contexts_ ;
73    bool finalizeSignal_ ;
74    shared_ptr<CEventScheduler> eventScheduler_ ;
75
76    std::string poolId_ ;
77    std::string serviceId_ ;
78    int partitionId_ ;
79    int type_ ;
80    int nbPartitions_ ;
81
82    const double eventLoopLatency_=0; 
83    double lastEventLoop_=0. ;
84
85  };
86
87}
88
89
90
91#endif
Note: See TracBrowser for help on using the repository browser.