#include <atomictypes.h>
Atomic reference counter.
Public Types | |
using | ValueType = UInt |
Public Member Functions | |
StrongReferenceCounter () | |
StrongReferenceCounter (const StrongReferenceCounter &) | |
void | operator= (const StrongReferenceCounter &) |
Bool | Inc () |
Bool | Dec () |
Bool | ConditionalInc () |
void | Add (UInt additionalReferences) |
void | SetRelaxed (UInt referenceCount) |
operator UInt () const | |
Bool | HasMultipleReferences () const |
Bool | HasMoreReferences (Int count) const |
Static Public Member Functions | |
static MAXON_ATTRIBUTE_FORCE_INLINE const StrongReferenceCounter & | NullValue () |
static StrongReferenceCounter & | Get (const void *object) |
Protected Attributes | |
AtomicUInt | _value |
StrongReferenceCounter | ( | const StrongReferenceCounter & | ) |
void operator= | ( | const StrongReferenceCounter & | ) |
Bool Inc | ( | ) |
Increments reference counter (the caller acquires a strong reference).
Bool Dec | ( | ) |
Decrements reference counter (the caller removes a strong reference).
Bool ConditionalInc | ( | ) |
Adds a reference if the object is still strongly referenced.
void Add | ( | UInt | additionalReferences | ) |
Adds references.
[in] | additionalReferences | The number of additional references to add. |
void SetRelaxed | ( | UInt | referenceCount | ) |
Sets a specifc reference count - for initialization only!
operator UInt | ( | ) | const |
Returns the number of strong references to the object.
Bool HasMultipleReferences | ( | ) | const |
Returns whether an object has more than a single reference. For an object without a reference it will return false. For an object with one strong reference it will return false. For an object with a single strong reference and weak references it will return true. For an object with two strong references it will return true.
Returns whether an object has more references then the given count. For an object without weak references and with at most count strong references it will return false. Otherwise, for an object with weak references or with more than count strong references it will return true.
|
static |
|
static |
Returns the reference counter for classes which do not implement custom AddReference/RemoveReference methods.
|
protected |