From 01cf7a585de2942562837077dff73968562b91f3 Mon Sep 17 00:00:00 2001 From: Martin Neupauer Date: Mon, 9 Jul 2018 16:20:02 -0700 Subject: SERVER-35940 Remove IntrusiveCounter --- src/mongo/util/intrusive_counter.cpp | 10 +------ src/mongo/util/intrusive_counter.h | 57 +----------------------------------- 2 files changed, 2 insertions(+), 65 deletions(-) diff --git a/src/mongo/util/intrusive_counter.cpp b/src/mongo/util/intrusive_counter.cpp index 75c3b0f0acc..0e788aa2f2c 100644 --- a/src/mongo/util/intrusive_counter.cpp +++ b/src/mongo/util/intrusive_counter.cpp @@ -58,12 +58,4 @@ intrusive_ptr RCString::create(StringData s) { return ptr; } -void IntrusiveCounterUnsigned::addRef() const { - ++counter; -} - -void IntrusiveCounterUnsigned::release() const { - if (!--counter) - delete this; -} -} +} // namespace mongo diff --git a/src/mongo/util/intrusive_counter.h b/src/mongo/util/intrusive_counter.h index 76c1bee5a78..0d3b5fc50bf 100644 --- a/src/mongo/util/intrusive_counter.h +++ b/src/mongo/util/intrusive_counter.h @@ -38,54 +38,6 @@ namespace mongo { -/* - IntrusiveCounter is a sharable implementation of a reference counter that - objects can use to be compatible with boost::intrusive_ptr<>. - - Some objects that use IntrusiveCounter are immutable, and only have - const methods. This may require their pointers to be declared as - intrusive_ptr . In order to be able to share pointers to - these immutables, the methods associated with IntrusiveCounter are declared - as const, and the counter itself is marked as mutable. - - IntrusiveCounter itself is abstract, allowing for multiple implementations. - For example, IntrusiveCounterUnsigned uses ordinary unsigned integers for - the reference count, and is good for situations where thread safety is not - required. For others, other implementations using atomic integers should - be used. For static objects, the implementations of addRef() and release() - can be overridden to do nothing. - */ -class IntrusiveCounter { - MONGO_DISALLOW_COPYING(IntrusiveCounter); - -public: - IntrusiveCounter() = default; - virtual ~IntrusiveCounter(){}; - - // these are here for the boost intrusive_ptr<> class - friend inline void intrusive_ptr_add_ref(const IntrusiveCounter* pIC) { - pIC->addRef(); - }; - friend inline void intrusive_ptr_release(const IntrusiveCounter* pIC) { - pIC->release(); - }; - - virtual void addRef() const = 0; - virtual void release() const = 0; -}; - -class IntrusiveCounterUnsigned : public IntrusiveCounter { -public: - // virtuals from IntrusiveCounter - virtual void addRef() const; - virtual void release() const; - - IntrusiveCounterUnsigned(); - -private: - mutable unsigned counter; -}; - /// This is an alternative base class to the above ones (will replace them eventually) class RefCountable { MONGO_DISALLOW_COPYING(RefCountable); @@ -151,11 +103,4 @@ private: int _size; // does NOT include trailing NUL byte. // char[_size+1] array allocated past end of class }; -}; - -/* ======================= INLINED IMPLEMENTATIONS ========================== */ - -namespace mongo { - -inline IntrusiveCounterUnsigned::IntrusiveCounterUnsigned() : counter(0) {} -}; +} // namespace mongo -- cgit v1.2.1