| | |
| | | #ifndef DEFS_KP8LKGD0 |
| | | #define DEFS_KP8LKGD0 |
| | | |
| | | #include "robust.h" |
| | | #include <atomic> |
| | | #include <string> |
| | | |
| | | class ShmSocket; |
| | | typedef uint64_t MQId; |
| | | |
| | | const MQId kBHTopicCenter = 100; |
| | | const MQId kBHTopicBus = 101; |
| | | const MQId kBHUniCenter = 102; |
| | | inline const MQId BHTopicCenterAddress() { return kBHTopicCenter; } |
| | | inline const MQId BHTopicBusAddress() { return kBHTopicBus; } |
| | | inline const MQId BHUniCenterAddress() { return kBHUniCenter; } |
| | | int64_t CalcAllocIndex(int64_t size); |
| | | int64_t GetAllocSize(int index); |
| | | |
| | | struct MQInfo { |
| | | MQId id_ = 0; |
| | | int64_t offset_ = 0; |
| | | }; |
| | | |
| | | struct CenterInfo { |
| | | MQInfo mq_center_; |
| | | MQInfo mq_bus_; |
| | | MQInfo mq_sender_; |
| | | robust::AtomicReqRep init_rr_; |
| | | }; |
| | | |
| | | const int kBHCenterPort = 24287; |
| | | const char kTopicSep = '.'; |
| | |
| | | class SharedMemory; |
| | | } // namespace bhome_shm |
| | | |
| | | using bhome_shm::SharedMemory; |
| | | |
| | | std::string BHomeShmName(); |
| | | bhome_shm::SharedMemory &BHomeShm(); |
| | | bool GlobalInit(bhome_shm::SharedMemory &shm); |
| | | SharedMemory &BHomeShm(); |
| | | CenterInfo *GetCenterInfo(SharedMemory &shm); |
| | | ShmSocket &DefaultSender(SharedMemory &shm); |
| | | |
| | | MQId NewSession(); |
| | | bool CenterInit(); |
| | | bool GlobalInit(SharedMemory &shm); |
| | | typedef std::string Topic; |
| | | void SetLastError(const int ec, const std::string &msg); |
| | | void GetLastError(int &ec, std::string &msg); |
| | | //TODO center can check shm for previous crash. |
| | | |
| | | const MQInfo &BHTopicCenterAddress(SharedMemory &shm); |
| | | const MQInfo &BHTopicBusAddress(SharedMemory &shm); |
| | | bool BHNodeInit(SharedMemory &shm, const int64_t request, int64_t &reply); |
| | | void BHCenterHandleInit(SharedMemory &shm, std::function<int64_t(const int64_t)> const &onReq); |
| | | |
| | | // node mq is avail with in timeout; after that may get killed. |
| | | int NodeTimeoutSec(); |
| | | |
| | | std::string BHLogDir(); |
| | | |
| | | #endif // end of include guard: DEFS_KP8LKGD0 |