lichao
2021-04-30 3b93dc0dc34008cf25b2b12f6b026b3d9e4ed623
src/shm.h
@@ -96,6 +96,7 @@
class SharedMemory : public mshm_t
{
   std::string name_;
   Mutex *pmutex_ = 0;
   static permissions AllowAll()
   {
@@ -122,19 +123,29 @@
   {
      return construct<T>(name.c_str(), std::nothrow)(std::forward<decltype(params)>(params)...);
   }
   void *Alloc(const size_t size) { return allocate(size, std::nothrow); }
   void *Alloc(const size_t size)
   {
      Guard lock(*pmutex_);
      return allocate(size, std::nothrow);
   }
   void Dealloc(void *p)
   {
      Guard lock(*pmutex_);
      if (p) { deallocate(p); }
   }
   template <class T>
   void Dealloc(offset_ptr<T> ptr) { return Dealloc(ptr.get()); }
   template <class T, class... Params>
   T *New(Params &&...params) { return construct<T>(anonymous_instance, std::nothrow)(std::forward<decltype(params)>(params)...); }
   T *New(Params &&...params)
   {
      Guard lock(*pmutex_);
      return construct<T>(anonymous_instance, std::nothrow)(std::forward<decltype(params)>(params)...);
   }
   template <class T>
   void Delete(T *p)
   {
      Guard lock(*pmutex_);
      if (p) { destroy_ptr<T>(p); };
   }
   template <class T>