NuRefCounted

A reference counted class.

Reference counted classes in numem are manually reference counted, this means that you are responsible for managing synchronising retain and release calls.

Threadsafety: Threadsafety depends on whether the hookset used supports atomic operations; see numem.core.atomic.nu_atomic_supported. If unsupported, retain and release will not be threadsafe on their own, and should be wrapped in another synchronisation primitive.

Memorysafety: Once the reference count for a class reaches 0, it will be destructed and freed automatically. All references to the class after refcount reaches 0 will be invalid and should not be used. NuRefCounted.release returns a value which can be used to determine whether the destructor was invoked.

Constructors

this
this()

Base constructor, all subclasses *have* to invoke this constructor. Otherwise the instance will be invalid on instantiation.

Members

Functions

autorelease
NuRefCounted autorelease()

Pushes this refcounted object to the topmost auto release pool.

isValid
bool isValid()

Returns whether this object is valid.

release
NuRefCounted release()

Releases a reference from a valid object.

retain
NuRefCounted retain()

Retains a reference to a valid object.

Properties

refs
uint refs [@property getter]

The current reference count of the object.

Inherited Members

From NuObject

toString
string toString()

Gets the name of the class.

opEquals
bool opEquals(Object other)

Test whether this is equal to other.

opCmp
int opCmp(Object other)

Compare with another Object other.

toHash
size_t toHash()

Compute a hash for Object.

Meta