diff options
Diffstat (limited to 'cpp/src/Ice/GC.cpp')
-rw-r--r-- | cpp/src/Ice/GC.cpp | 56 |
1 files changed, 14 insertions, 42 deletions
diff --git a/cpp/src/Ice/GC.cpp b/cpp/src/Ice/GC.cpp index 40372534131..83b282c9473 100644 --- a/cpp/src/Ice/GC.cpp +++ b/cpp/src/Ice/GC.cpp @@ -78,52 +78,11 @@ using namespace IceInternal; // // GCShared // - void IceInternal::GCShared::__incRef() { IceUtilInternal::MutexPtrLock<IceUtil::RecMutex> lock(gcRecMutex); assert(_ref >= 0); - ++_ref; -} - -void -IceInternal::GCShared::__decRef() -{ - IceUtilInternal::MutexPtrLock<IceUtil::RecMutex> lock(gcRecMutex); - bool doDelete = false; - assert(_ref > 0); - if(--_ref == 0) - { - doDelete = !_noDelete; - _noDelete = true; - } - lock.release(); - if(doDelete) - { - delete this; - } -} - -int -IceInternal::GCShared::__getRef() const -{ - IceUtilInternal::MutexPtrLock<IceUtil::RecMutex> lock(gcRecMutex); - return _ref; -} - -void -IceInternal::GCShared::__setNoDelete(bool b) -{ - IceUtilInternal::MutexPtrLock<IceUtil::RecMutex> lock(gcRecMutex); - _noDelete = b; -} - -void -IceInternal::GCShared::__gcIncRef() -{ - IceUtilInternal::MutexPtrLock<IceUtil::RecMutex> lock(gcRecMutex); - assert(_ref >= 0); if(_ref == 0 && gcObjects != 0) { #ifdef NDEBUG // To avoid annoying warnings about variables that are not used... @@ -137,7 +96,7 @@ IceInternal::GCShared::__gcIncRef() } void -IceInternal::GCShared::__gcDecRef() +IceInternal::GCShared::__decRef() { IceUtilInternal::MutexPtrLock<IceUtil::RecMutex> lock(gcRecMutex); bool doDelete = false; @@ -160,6 +119,19 @@ IceInternal::GCShared::__gcDecRef() } } +int +IceInternal::GCShared::__getRef() const +{ + IceUtilInternal::MutexPtrLock<IceUtil::RecMutex> lock(gcRecMutex); + return _ref; +} + +void +IceInternal::GCShared::__setNoDelete(bool b) +{ + IceUtilInternal::MutexPtrLock<IceUtil::RecMutex> lock(gcRecMutex); + _noDelete = b; +} // // GC |