20 #define mInvalidRefCount (-1) 121 #define mRefCountImplWithDestructor(ClassName, DestructorImpl, delfunc ) \ 129 bool refIfReffed() const \ 131 if ( !refcount_.refIfReffed() ) \ 140 if ( refcount_.unRef() ) \ 145 void unRefNoDelete() const \ 147 unRefNoDeleteNotify(); \ 148 refcount_.unRefDontInvalidate(); \ 150 int nrRefs() const { return refcount_.count(); } \ 152 virtual void refNotify() const {} \ 153 virtual void unRefNotify() const {} \ 154 virtual void unRefNoDeleteNotify() const {} \ 155 mutable ReferenceCounter refcount_; \ 163 #define mRefCountImpl(ClassName) \ 164 mRefCountImplWithDestructor(ClassName, virtual ~ClassName(), delete this; ); 167 #define mRefCountImplNoDestructor(ClassName) \ 168 mRefCountImplWithDestructor(ClassName, virtual ~ClassName() {}, delete this; ); 171 template <
class T>
inline 181 template <
class T>
inline 190 template <
class T>
inline 194 ptr->unRefNoDelete();
199 template <
class T>
inline 223 inline void unRefDontInvalidate();
227 inline bool refIfReffed();
237 # define mDeclareCounters od_int32 oldcount = count_.get(), newcount = 0 239 # define mDeclareCounters od_int32 oldcount = count_.get(), newcount; 260 newcount = oldcount+1;
283 else if ( oldcount==1 )
286 newcount = oldcount-1;
309 else if ( !oldcount )
312 newcount = oldcount+1;
337 newcount = oldcount-1;
342 #undef mDeclareCounters bool setIfValueIs(T curval, T newval, T *actualvalptr)
Definition: atomic.h:398
Definition: refcount.h:215
void deepUnRefNoDelete(ObjectSet< T > &os)
Definition: refcount.h:208
void ref()
Definition: refcount.h:242
void unRefPtr(const T *ptr)
Definition: refcount.h:182
void unRefNoDeletePtr(const T *ptr)
Definition: refcount.h:191
#define mDeclareCounters
Definition: refcount.h:239
bool refIfReffed()
Don't use in production, for debugging.
Definition: refcount.h:294
void refPtr(const T *ptr)
Reference class pointer. Works for null pointers.
Definition: refcount.h:200
#define od_int32
Definition: plftypes.h:31
int count() const
Definition: refcount.h:226
#define mInvalidRefCount
Definition: refcount.h:20
void forceCrash(bool withdump)
#define mObjectSetApplyToAllFunc(fn, op, extra)
Definition: objectset.h:108
void deepUnRef(ObjectSet< T > &os)
Definition: refcount.h:206
#define mClass(module)
Definition: commondefs.h:164
void deepRef(ObjectSet< T > &os)
Definition: refcount.h:209
#define pErrMsg(msg)
Definition: errmsg.h:60
void unRefDontInvalidate()
Will allow it to go to zero.
Definition: refcount.h:320
bool unRef()
Definition: refcount.h:267
Threads::Atomic< int > count_
Definition: refcount.h:232
void unRefAndZeroPtr(T *&ptr)
Un-reference class pointer, and set it to zero. Works for null-pointers.
Definition: refcount.h:172