ThreadSafeRefCount
Engine/source/platform/threads/threadSafeRefCount.h
Baseclass for concurrently reference-counted objects.
Public Types
Parent
Protected Attributes
Public Functions
Public Static Functions
Protected Static Functions
decrementAndTestAndSet(U32 & refCount)
Decrement the given reference count.
Detailed Description
Baseclass for concurrently reference-counted objects.
note:Parameters:NOTE that freshly instantiated objects start out with a reference count of ZERO! Depending on how this class is used, this may not be desirable, so override this behavior in constructors if necessary.
T | the class being reference counted; this is passed to this class, so it can call the correct destructor without having to force users to have virtual methods |
Public Types
typedef void Parent
Protected Attributes
U32 mRefCount
Reference count and claim bit. Note that this increments in steps of two.
Public Functions
ThreadSafeRefCount()
ThreadSafeRefCount(bool noSet)
addRef()
Increase the reference count on the object.
clearLowestBit()
getRefCount()
Get the current reference count.
This method is mostly meant for debugging and should not normally be used.
isShared()
true if the object is referenced by more than a single reference.
release()
Decrease the object's reference count and delete the object, if the count drops to zero and claiming the object by the current thread succeeds.
Public Static Functions
safeRead(T *const volatile & refPtr)
Dereference a reference-counted pointer in a multi-thread safe way.
Protected Static Functions
decrementAndTestAndSet(U32 & refCount)
Decrement the given reference count.
Return 1 if the count dropped to zero and the claim bit has been successfully set; return 0 otherwise.