AtomicRefCounted

A atomic reference counted resource. Objects implementing this interface can be safely used as shared.

Important note: AtomicRefCounted extends RefCounted (non-atomic). If it is implemented using mixedRcCode, then the following statements apply - When the object is shared, the atomic reference count is used. - When the object is not shared, the non-atomic reference count is used.

Although this sounds neat, it makes certain things quite difficult to implement Eg. having some rc in a parallel loop. (parallel spawns threads without any guard or lock - see the gfx-d:shadow example) For that reason, the atomicRcCode enum is available that implements both RefCounted and AtomicRefCounted atomically.

Members

Functions

rcLock
shared(AtomicRefCounted) rcLock()

Get a copy of this RefCounted instance if the refCount >= 1. This increases the refCount by 1. This should only be used to keep weak reference and ensures that the resource is not disposed. The operation is atomic.

release
void release()

Atomically decrement the reference count and dispose if it reaches zero. The object is locked using its own mutex when dispose is called.

retain
void retain()

Atomically increment the reference count.

Properties

refCount
size_t refCount [@property getter]

Atomically load the number of active references.

Inherited Members

From RefCounted

refCount
size_t refCount [@property getter]

The number of active references

retain
void retain()

Increment the reference count.

release
void release()

Decrement the reference count and dispose if it reaches zero.

rcLock
RefCounted rcLock()

Get a copy of this RefCounted instance if the refCount >= 1. This increases the refCount by 1. This should only be used to keep weak reference and ensures that the resource is not disposed.

dispose
void dispose()
Undocumented in source.

Meta