[342] | 1 | #ifndef __SERVER_HPP__ |
---|
| 2 | #define __SERVER_HPP__ |
---|
[300] | 3 | |
---|
[591] | 4 | #include "xios_spl.hpp" |
---|
[300] | 5 | #include "context.hpp" |
---|
[697] | 6 | #include "context_client.hpp" |
---|
[382] | 7 | #include "mpi.hpp" |
---|
[492] | 8 | #include "event_scheduler.hpp" |
---|
[300] | 9 | |
---|
[335] | 10 | namespace xios |
---|
[300] | 11 | { |
---|
| 12 | class CServer |
---|
| 13 | { |
---|
[523] | 14 | public: |
---|
| 15 | static void initialize(void); |
---|
| 16 | static void finalize(void); |
---|
| 17 | static void eventLoop(void); |
---|
| 18 | static void contextEventLoop(void); |
---|
| 19 | static void listenContext(void); |
---|
| 20 | static void listenFinalize(void); |
---|
| 21 | static void recvContextMessage(void* buff,int count); |
---|
| 22 | static void listenRootContext(void); |
---|
| 23 | static void listenRootFinalize(void); |
---|
| 24 | static void registerContext(void* buff,int count, int leaderRank=0); |
---|
[490] | 25 | |
---|
[523] | 26 | static MPI_Comm intraComm; |
---|
| 27 | static list<MPI_Comm> interComm; |
---|
[655] | 28 | static std::list<MPI_Comm> contextInterComms; |
---|
[523] | 29 | static CEventScheduler* eventScheduler; |
---|
[697] | 30 | |
---|
[523] | 31 | struct contextMessage |
---|
| 32 | { |
---|
| 33 | int nbRecv; |
---|
| 34 | int leaderRank; |
---|
| 35 | }; |
---|
[300] | 36 | |
---|
[523] | 37 | static bool isRoot; |
---|
[490] | 38 | |
---|
[523] | 39 | static map<string,CContext*> contextList; |
---|
| 40 | static bool finished; |
---|
| 41 | static bool is_MPI_Initialized; |
---|
[490] | 42 | |
---|
[523] | 43 | public: |
---|
| 44 | //! Get rank of the current process |
---|
| 45 | static int getRank(); |
---|
[490] | 46 | |
---|
[523] | 47 | //! Open a file stream to write the info logs |
---|
[490] | 48 | static void openInfoStream(const StdString& fileName); |
---|
[523] | 49 | //! Write the info logs to standard output |
---|
[490] | 50 | static void openInfoStream(); |
---|
[523] | 51 | //! Close the info logs file if it opens |
---|
[490] | 52 | static void closeInfoStream(); |
---|
| 53 | |
---|
[523] | 54 | //! Open a file stream to write the error log |
---|
| 55 | static void openErrorStream(const StdString& fileName); |
---|
| 56 | //! Write the error log to standard error output |
---|
| 57 | static void openErrorStream(); |
---|
| 58 | //! Close the error log file if it opens |
---|
| 59 | static void closeErrorStream(); |
---|
| 60 | |
---|
| 61 | private: |
---|
| 62 | static int rank; |
---|
[490] | 63 | static StdOFStream m_infoStream; |
---|
[523] | 64 | static StdOFStream m_errorStream; |
---|
| 65 | |
---|
| 66 | static void openStream(const StdString& fileName, const StdString& ext, std::filebuf* fb); |
---|
| 67 | }; |
---|
[300] | 68 | } |
---|
| 69 | |
---|
| 70 | #endif |
---|