Adds reference-counting to an object. More...
|void||incReferenceCount () noexcept|
|Increments the object's reference count. |
|void||decReferenceCount () noexcept|
|Decreases the object's reference count. |
|int||getReferenceCount () const noexcept|
|Returns the object's current reference count. |
|Creates the reference-counted object (with an initial ref count of zero). |
|void||resetReferenceCount () noexcept|
|Resets the reference count to zero without deleting the object. |
Adds reference-counting to an object.
To add reference-counting to a class, derive it from this class, and use the ReferenceCountedObjectPtr class to point to it.
Once a new ReferenceCountedObject has been assigned to a pointer, be careful not to delete the object manually.
This class uses an Atomic<int> value to hold the reference count, so that it the pointers can be passed between threads safely. For a faster but non-thread-safe version, use SingleThreadedReferenceCountedObject instead.
Creates the reference-counted object (with an initial ref count of zero).
Increments the object's reference count.
This is done automatically by the smart pointer, but is public just in case it's needed for nefarious purposes.
Decreases the object's reference count.
If the count gets to zero, the object will be deleted.
Referenced by ReferenceCountedArray< SynthesiserSound >::removeAndReturn().
Returns the object's current reference count.
Resets the reference count to zero without deleting the object.
You should probably never need to use this!