lichao
2021-05-14 9bf199a4770b08c03d553129757d960b605e598a
src/shm.h
@@ -192,6 +192,12 @@
         pdata_ = shm_.Find<Data>(ObjName(name_));
      }
   }
   ShmObject(const int64_t offset, ShmType &segment, const std::string &name) :
       shm_(segment), name_(name)
   {
      pdata_ = reinterpret_cast<Data *>(Addr(shm_.get_address()) + offset);
   }
   bool IsOk() const { return pdata_; }
   static bool Remove(SharedMemory &shm, const std::string &name) { return shm.destroy<Data>(ObjName(name).c_str()); }
@@ -201,11 +207,13 @@
   std::string name() const { return name_; }
   Data *data() { return pdata_; }
   const Data *data() const { return pdata_; }
   int64_t offset() const { return Addr(pdata_) - Addr(shm_.get_address()); }
   Data *operator->() { return data(); }
   const Data *operator->() const { return data(); }
   bool Remove() { return Remove(shm_, name_); }
private:
   static int64_t Addr(const void *p) { return reinterpret_cast<int64_t>(p); }
   ShmType &shm_;
   std::string name_;
   Data *pdata_ = nullptr;