X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fstructure%2FSGReferenced.hxx;h=67e4fb1ed18ba36b7d42d206dfd9155047d0a0ee;hb=9da0031039bb534011591ce3bd6fede21030c345;hp=13f929954b48df485cb0c21e581f810702d26f3a;hpb=dcb95d131bc6aef1abe25d1f415e309f06e52436;p=simgear.git diff --git a/simgear/structure/SGReferenced.hxx b/simgear/structure/SGReferenced.hxx index 13f92995..67e4fb1e 100644 --- a/simgear/structure/SGReferenced.hxx +++ b/simgear/structure/SGReferenced.hxx @@ -21,10 +21,14 @@ #ifndef SGReferenced_HXX #define SGReferenced_HXX +#include "SGAtomic.hxx" + /// 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: @@ -38,16 +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: - mutable unsigned _refcount; + mutable SGAtomic _refcount; }; #endif