Index: base/memory/ref_counted.h |
diff --git a/base/memory/ref_counted.h b/base/memory/ref_counted.h |
index 1207ed4cdbb572ae274d5a9c3ac353d698688ed7..d8ed15035e5c6cce1200f0ac8cf026441eee5355 100644 |
--- a/base/memory/ref_counted.h |
+++ b/base/memory/ref_counted.h |
@@ -116,6 +116,26 @@ struct DefaultRefCountedThreadSafeTraits { |
} |
}; |
+// Use as Traits parameter to RefCountedThreadSafe in order to override how the |
+// RefCountedThreadSafe subclass is destroyed. |
+// |
+// class MyFoo : public base::RefCountedThreadSafe<MyFoo, ManualDestruction> { |
+// ... |
+// private: |
+// friend class ManualDestruction; |
+// void DoManualDestruction() { |
+// delete this; // Or something else that's appropriate. |
+// } |
+// }; |
+// |
+class ManualDestruction { |
+ public: |
+ template <class T> |
+ static void Destruct(const T* x) { |
+ T::DoManualDestruction(x); |
+ } |
+}; |
+ |
// |
// A thread-safe variant of RefCounted<T> |
// |