[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; |
---|
| 27 | static CEventScheduler* eventScheduler; |
---|
[490] | 28 | |
---|
[523] | 29 | struct contextMessage |
---|
| 30 | { |
---|
| 31 | int nbRecv; |
---|
| 32 | int leaderRank; |
---|
| 33 | }; |
---|
[300] | 34 | |
---|
[523] | 35 | static bool isRoot; |
---|
[490] | 36 | |
---|
[523] | 37 | static map<string,CContext*> contextList; |
---|
| 38 | static bool finished; |
---|
| 39 | static bool is_MPI_Initialized; |
---|
[490] | 40 | |
---|
[523] | 41 | public: |
---|
| 42 | //! Get rank of the current process |
---|
| 43 | static int getRank(); |
---|
[490] | 44 | |
---|
[523] | 45 | //! Open a file stream to write the info logs |
---|
[490] | 46 | static void openInfoStream(const StdString& fileName); |
---|
[523] | 47 | //! Write the info logs to standard output |
---|
[490] | 48 | static void openInfoStream(); |
---|
[523] | 49 | //! Close the info logs file if it opens |
---|
[490] | 50 | static void closeInfoStream(); |
---|
| 51 | |
---|
[523] | 52 | //! Open a file stream to write the error log |
---|
| 53 | static void openErrorStream(const StdString& fileName); |
---|
| 54 | //! Write the error log to standard error output |
---|
| 55 | static void openErrorStream(); |
---|
| 56 | //! Close the error log file if it opens |
---|
| 57 | static void closeErrorStream(); |
---|
| 58 | |
---|
| 59 | private: |
---|
| 60 | static int rank; |
---|
[490] | 61 | static StdOFStream m_infoStream; |
---|
[523] | 62 | static StdOFStream m_errorStream; |
---|
| 63 | |
---|
| 64 | static void openStream(const StdString& fileName, const StdString& ext, std::filebuf* fb); |
---|
| 65 | }; |
---|
[300] | 66 | } |
---|
| 67 | |
---|
| 68 | #endif |
---|