#include <cel_referable.h>
Public Member Functions | |
Referable () | |
void | addRef () const |
void | releaseRef () const |
size_t | getReferenceCount () const |
Static Public Member Functions | |
static void | dumpDbgAllRefCount () |
Referable is an abstract class that provides object lifetime management feature using reference count. On the first time the object is created, it's reference count is 1. This means someone is referring to the object. And then another one may want to refer to the object, then it increments the reference count by calling addRef. If a referrer no longer need to refer it, it should call releaseRef, releaseRef decrements the reference count. If the reference count becomes 0, then the object is released (deleted).
The Referable class uses thread-safe increment/decrement mechanism.
Celartem::Referable::Referable | ( | ) |
The constructor resets the reference count to 0.
void Celartem::Referable::addRef | ( | ) | const |
This method increments the reference count.
|
static |
For internal uses only.
|
inline |
This method obtains the current reference count of the instance. For thread-safety, you should not depend on this method.
void Celartem::Referable::releaseRef | ( | ) | const |
This method decrements the reference count and if the reference count becomes 0, it also delete the instance.