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