diff options
author | Michi Henning <michi@zeroc.com> | 2003-10-23 06:22:17 +0000 |
---|---|---|
committer | Michi Henning <michi@zeroc.com> | 2003-10-23 06:22:17 +0000 |
commit | 0fdb3361e7525f4f49556d1233d9b84c566ec6fb (patch) | |
tree | f128daba58f02bfc2c3a4d975c001eeab2562b43 /cpp/include/IceUtil/ObjectBase.h | |
parent | fixes (diff) | |
download | ice-0fdb3361e7525f4f49556d1233d9b84c566ec6fb.tar.bz2 ice-0fdb3361e7525f4f49556d1233d9b84c566ec6fb.tar.xz ice-0fdb3361e7525f4f49556d1233d9b84c566ec6fb.zip |
- Renamed ObjectBase to GCShared.
- Fixed the problem of the gc test sometimes running for over three
minutes.
- Fixed race condition in printGCStats if a signal caused communicator
shutdown.
Diffstat (limited to 'cpp/include/IceUtil/ObjectBase.h')
-rw-r--r-- | cpp/include/IceUtil/ObjectBase.h | 147 |
1 files changed, 0 insertions, 147 deletions
diff --git a/cpp/include/IceUtil/ObjectBase.h b/cpp/include/IceUtil/ObjectBase.h deleted file mode 100644 index 664a2745657..00000000000 --- a/cpp/include/IceUtil/ObjectBase.h +++ /dev/null @@ -1,147 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003 -// ZeroC, Inc. -// Billerica, MA, USA -// -// All Rights Reserved. -// -// Ice is free software; you can redistribute it and/or modify it under -// the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation. -// -// ********************************************************************** - -#ifndef ICE_UTIL_OBJECTBASE_H -#define ICE_UTIL_OBJECTBASE_H - -#include <IceUtil/GCRecMutex.h> -#include <set> - -namespace IceUtil -{ - -class GC; -class ObjectBase; - -typedef std::set<ObjectBase*> ObjectSet; -extern ICE_UTIL_API ObjectSet objects; // Set of pointers to all existing classes. - -typedef std::multiset<ObjectBase*> ObjectMultiSet; - -class ICE_UTIL_API ObjectBase : public noncopyable -{ -public: - - ObjectBase(); - virtual ~ObjectBase(); - void __incRef(); - void __decRef(); - int __getRef() const; - void __setNoDelete(bool); - void __decRefUnsafe(); - virtual void __gcReachable(ObjectMultiSet&) const = 0; - virtual void __gcClear() = 0; - -protected: - - static void __addObject(ObjectMultiSet&, ObjectBase*); - -private: - - int _ref; - bool _noDelete; - bool _adopted; - - friend class IceUtil::GC; -}; - -inline -ObjectBase::ObjectBase() -{ - gcRecMutex._m->lock(); - _ref = 0; - _noDelete = false; - _adopted = false; - gcRecMutex._m->unlock(); -} - -inline -ObjectBase::~ObjectBase() -{ - gcRecMutex._m->lock(); - ObjectSet::size_type num = objects.erase(this); - assert(num == 1); - gcRecMutex._m->unlock(); -} - -inline void -ObjectBase::__incRef() -{ - gcRecMutex._m->lock(); - assert(_ref >= 0); - if(!_adopted && _ref == 0) - { - _adopted = true; - std::pair<ObjectSet::iterator, bool> rc = objects.insert(this); - assert(rc.second); - } - ++_ref; - gcRecMutex._m->unlock(); -} - -inline void -ObjectBase::__decRef() -{ - gcRecMutex._m->lock(); - bool doDelete = false; - assert(_ref > 0); - if(--_ref == 0) - { - doDelete = !_noDelete; - _noDelete = true; - } - if(doDelete) - { - delete this; - } - gcRecMutex._m->unlock(); -} - -inline int -ObjectBase::__getRef() const -{ - gcRecMutex._m->lock(); - int ref = _ref; - gcRecMutex._m->unlock(); - return ref; -} - -inline void -ObjectBase::__setNoDelete(bool b) -{ - gcRecMutex._m->lock(); - _noDelete = b; - gcRecMutex._m->unlock(); -} - -inline void -ObjectBase::__decRefUnsafe() -{ - --_ref; -} - -inline void -ObjectBase::__addObject(ObjectMultiSet& c, ObjectBase* p) -{ - gcRecMutex._m->lock(); - if(p) - { - c.insert(p); - } - gcRecMutex._m->unlock(); -} - -} - -#endif |