1 | #ifndef __SERVER_CONTEXT_HPP__ |
---|
2 | #define __SERVER_CONTEXT_HPP__ |
---|
3 | #include "xios_spl.hpp" |
---|
4 | #include "window_manager.hpp" |
---|
5 | #include "mpi.hpp" |
---|
6 | |
---|
7 | namespace xios |
---|
8 | { |
---|
9 | class CContext ; |
---|
10 | class CService ; |
---|
11 | |
---|
12 | class CServerContext |
---|
13 | { |
---|
14 | const int NOTIFY_NOTHING=0 ; |
---|
15 | const int NOTIFY_CREATE_INTERCOMM=1 ; |
---|
16 | |
---|
17 | public: |
---|
18 | CServerContext(CService* parentService, MPI_Comm contextComm, const std::string& poolId, const std::string& serviceId, |
---|
19 | const int& partitionId, const std::string& contextId) ; |
---|
20 | ~CServerContext() ; |
---|
21 | static void releaseStaticAllocation(void) { overlapedComm_.clear() ;} |
---|
22 | |
---|
23 | bool createIntercomm(const string& poolId, const string& serviceId, const int& partitionId, const string& contextId, |
---|
24 | const MPI_Comm& intraComm, MPI_Comm& interCommClient, MPI_Comm& interCommServer, bool wait=true) ; |
---|
25 | void createIntercomm(int remoteLeader, const string& sourceContext) ; |
---|
26 | |
---|
27 | void sendNotification(int rank); |
---|
28 | void checkNotifications(void) ; |
---|
29 | |
---|
30 | bool eventLoop(bool serviceOnly=false) ; |
---|
31 | void threadEventLoop(void) ; |
---|
32 | void notificationsDumpOut(CBufferOut& buffer) ; |
---|
33 | void notificationsDumpIn(CBufferIn& buffer) ; |
---|
34 | void finalizeSignal(void) ; |
---|
35 | void freeComm(void) ; |
---|
36 | CService* getParentService(void) {return parentService_ ; } |
---|
37 | |
---|
38 | private : |
---|
39 | bool finished_=false ; |
---|
40 | public: |
---|
41 | bool isFinished(void) { return finished_ ; } |
---|
42 | private: |
---|
43 | void createIntercomm(void) ; |
---|
44 | |
---|
45 | static std::map<std::string, std::tuple<bool, MPI_Comm, MPI_Comm> > overlapedComm_ ; |
---|
46 | |
---|
47 | MPI_Comm contextComm_ ; |
---|
48 | MPI_Comm xiosComm_ ; |
---|
49 | |
---|
50 | CContext* context_ ; |
---|
51 | CService* parentService_ ; |
---|
52 | std::string name_ ; |
---|
53 | |
---|
54 | vector<MPI_Comm> clientsInterComm_ ; |
---|
55 | |
---|
56 | |
---|
57 | const size_t maxBufferSize_=1024*1024 ; |
---|
58 | CWindowManager* winNotify_ ; |
---|
59 | int notifyInType_, notifyOutType_ ; |
---|
60 | tuple<int, std::string> notifyInCreateIntercomm_, notifyOutCreateIntercomm_ ; |
---|
61 | |
---|
62 | const int localLeader_=0 ; |
---|
63 | int globalLeader_ ; |
---|
64 | bool finalizeSignal_ ; |
---|
65 | bool hasNotification_ ; |
---|
66 | |
---|
67 | const double eventLoopLatency_=0; |
---|
68 | double lastEventLoop_=0. ; |
---|
69 | |
---|
70 | friend class CWindowManager ; |
---|
71 | } ; |
---|
72 | |
---|
73 | } |
---|
74 | |
---|
75 | #endif |
---|