The CYIReferenceCounter class is a counter used by both CYISharedPtr and CYIWeakPtr to count how many strong and weak references there are with a given piece of shared data.
The reference counters are atomic and therefore thread-safe.
#include <smartptr/YiReferenceCounter.h>
| CYIReferenceCounter::CYIReferenceCounter |
( |
| ) |
|
|
inline |
Default constructor. Upon instantiation, the strong and the weak reference count will both automatically start to 1 for you. This class is typically only instantiated by the CYISharedPtr. The CYISharedPtr contributes to both strong and weak reference counts, where the CYIWeakPtr contributes only to the weak reference count. The strong reference is used to determine if the shared data needs to be deleted, and the weak reference is used to determine if the reference counter itself needs to be deleted.
| CYIReferenceCounter::~CYIReferenceCounter |
( |
| ) |
|
|
inline |
| uint32_t CYIReferenceCounter::GetStrongRefCount |
( |
| ) |
const |
|
inline |
Returns the current strong reference count. If the value is zero, it is a valid indication that the CYISharedPtr data pointer was deleted.
| uint32_t CYIReferenceCounter::GetWeakRefCount |
( |
| ) |
const |
|
inline |
Returns the current weak reference count. If the value is zero, it is a valid indication that both the CYISharedPtr data pointer and the CYIReferenceCounter itself were deleted.
| uint32_t CYIReferenceCounter::StrongDeref |
( |
| ) |
|
|
inline |
This function decreases the strong reference count by -1.
- Returns
- returns the new value of the strong reference count
| uint32_t CYIReferenceCounter::StrongRef |
( |
| ) |
|
|
inline |
This function increases the strong reference count by +1.
- Returns
- returns the new value of the strong reference count
| uint32_t CYIReferenceCounter::WeakDeref |
( |
| ) |
|
|
inline |
This function decreases the weak reference count by -1.
- Returns
- returns the new value of the weak reference count
| uint32_t CYIReferenceCounter::WeakRef |
( |
| ) |
|
|
inline |
This function increases the weak reference count by +1.
- Returns
- returns the new value of the weak reference count
The documentation for this class was generated from the following file: