]> git.mxchange.org Git - simgear.git/blobdiff - simgear/structure/SGReferenced.hxx
Fix use count for deleted, reference counted objects.
[simgear.git] / simgear / structure / SGReferenced.hxx
index 6bce1eb82bd83da9e4fce1d88e37c414340baf91..67e4fb1ed18ba36b7d42d206dfd9155047d0a0ee 100644 (file)
 
 #ifndef SGReferenced_HXX
 #define SGReferenced_HXX
-#define USE_OPENTHREADS_ATOMIC
 
-#ifndef USE_OPENTHREADS_ATOMIC
 #include "SGAtomic.hxx"
-#else
-#include <OpenThreads/Atomic>
-#endif
 
 /// Base class for all reference counted SimGear objects
 /// Classes derived from this one are meant to be managed with
 /// the SGSharedPtr class.
-/// For more info see @SGSharedPtr.
+///
+/// For more info see SGSharedPtr. For using weak references see
+/// SGWeakReferenced.
 
 class SGReferenced {
 public:
@@ -45,20 +42,16 @@ public:
   { return *this; }
 
   static unsigned get(const SGReferenced* ref)
-  { if (ref) return ++(ref->_refcount); else return ~0u; }
+  { if (ref) return ++(ref->_refcount); else return 0; }
   static unsigned put(const SGReferenced* ref)
-  { if (ref) return --(ref->_refcount); else return ~0u; }
+  { if (ref) return --(ref->_refcount); else return 0; }
   static unsigned count(const SGReferenced* ref)
-  { if (ref) return ref->_refcount; else return ~0u; }
+  { if (ref) return ref->_refcount; else return 0; }
   static bool shared(const SGReferenced* ref)
   { if (ref) return 1u < ref->_refcount; else return false; }
 
 private:
-#ifndef USE_OPENTHREADS_ATOMIC
   mutable SGAtomic _refcount;
-#else
-  mutable OpenThreads::Atomic _refcount;
-#endif
 };
 
 #endif