lichao
2021-05-18 3788226ee9332945e90066b58f2b85026c2a0460
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,