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.
Atomically decrement the reference count and dispose if it reaches zero. The object is locked using its own mutex when dispose is called.
Atomically increment the reference count.
Atomically load the number of active references.
The number of active references
Increment the reference count.
Decrement the reference count and dispose if it reaches zero.
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.
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.