From 58d904a328c0d849769b483e901a0be9426b8209 Mon Sep 17 00:00:00 2001 From: liuxiaolong <liuxiaolong@aiotlink.com> Date: 星期二, 20 七月 2021 20:20:44 +0800 Subject: [PATCH] 调整Request C.BHFree的位置 --- src/defs.h | 54 +++++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 49 insertions(+), 5 deletions(-) diff --git a/src/defs.h b/src/defs.h index 40421e0..ec41371 100644 --- a/src/defs.h +++ b/src/defs.h @@ -19,13 +19,57 @@ #ifndef DEFS_KP8LKGD0 #define DEFS_KP8LKGD0 -#include <boost/uuid/uuid.hpp> -#include <boost/uuid/uuid_generators.hpp> +#include "robust.h" +#include <atomic> +#include <string> -typedef boost::uuids::uuid MQId; +class ShmSocket; +typedef uint64_t MQId; -const MQId kBHBusQueueId = boost::uuids::string_generator()("01234567-89ab-cdef-8349-1234567890ff"); +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; -//TODO center can check shm for previous crash. +const char kTopicSep = '.'; +namespace bhome_shm +{ +class SharedMemory; +} // namespace bhome_shm + +using bhome_shm::SharedMemory; + +std::string BHomeShmName(); +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); + +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 -- Gitblit v1.8.0