]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common: Added a custom deleter to make a sub-class work with std::unique_ptr
authorAmnon Hanuhov <ahanukov@redhat.com>
Tue, 16 Mar 2021 13:37:16 +0000 (15:37 +0200)
committerAmnon Hanuhov <ahanukov@redhat.com>
Thu, 6 May 2021 17:22:05 +0000 (20:22 +0300)
Signed-off-by: Amnon Hanuhov <ahanukov@redhat.com>
src/common/RefCountedObj.h

index b23f488cad90ba815286470e058b766e458b8f5c..2de1cf14ef3be19c8f81831488330600a59d0986 100644 (file)
@@ -193,6 +193,14 @@ static inline void intrusive_ptr_add_ref(const RefCountedObject *p) {
 static inline void intrusive_ptr_release(const RefCountedObject *p) {
   p->put();
 }
+struct UniquePtrDeleter
+{
+  void operator()(RefCountedObject *p) const
+  {
+    // Don't expect a call to `get()` in the ctor as we manually set nref to 1
+    p->put();
+  }
+};
 }
 using RefCountedPtr = ceph::ref_t<TOPNSPC::common::RefCountedObject>;