From 3788226ee9332945e90066b58f2b85026c2a0460 Mon Sep 17 00:00:00 2001 From: lichao <lichao@aiotlink.com> Date: 星期二, 18 五月 2021 10:56:32 +0800 Subject: [PATCH] change node init, no shm lock any more. --- src/msg.h | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-) diff --git a/src/msg.h b/src/msg.h index 9589389..e8af3c5 100644 --- a/src/msg.h +++ b/src/msg.h @@ -36,7 +36,10 @@ class ShmMsg : private StaticDataRef<SharedMemory, ShmMsg> { +public: static inline SharedMemory &shm() { return GetData(); } + +private: static ShmSocket &Sender(); // store ref count, msgs shareing the same data should also hold a pointer of the same RefCount object. @@ -74,6 +77,7 @@ const uint32_t size_ = 0; const int64_t id_ = 0; std::atomic<int64_t> timestamp_; + bool managed_ = false; Meta(uint32_t size) : size_(size), id_(NewId()), timestamp_(NowSec()) {} }; @@ -151,6 +155,10 @@ int AddRef() const { return valid() ? meta()->count_.Inc() : 1; } int Release(); void Free(); + void reset_managed(const bool val) const + { + if (valid()) { meta()->managed_ = val; } + } template <class Body> inline bool Make(const BHMsgHead &head, const Body &body) @@ -224,7 +232,7 @@ constexpr inline bool IsCmd(int64_t msg) { return (msg & 1) != 0; } // int64_t pack format: cmd data ,3bit cmd, 1bit flag. enum MsgCmd { - eCmdNodeInit = 0, // upto 59bit ssn id + eCmdNodeInit = 0, // upto 56bit ssn id eCmdNodeInitReply = 1, // 31bit proc index, eCmdAllocRequest0 = 2, // 8bit size, 4bit socket index, 16bit proc index, 28bit id eCmdAllocReply0 = 3, // 31bit ptr, 28bit id, -- Gitblit v1.8.0