RefCounted
#include <icy/memory.h>
template<typename T>
class RefCountedDefined in src/base/include/icy/memory.h:57
Embeds the refcount in the object itself - no separate control block allocation, no atomic operations. Safe for single-threaded libuv loops.
Usage: inherit from RefCounted, then use IntrusivePtr instead of std::shared_ptr.
Public Methods
| Return | Name | Description |
|---|---|---|
RefCounted | Defaulted constructor. | |
RefCounted inline noexcept | ||
RefCounted & | operator= inline noexcept | |
void | addRef const inline noexcept | Increments the reference count. Called by IntrusivePtr on acquisition. |
bool | releaseRef const inline noexcept | Decrements the reference count. |
int | refCount const inline noexcept | Returns the current reference count. |
RefCounted
RefCounted() = defaultDefined in src/base/include/icy/memory.h:60
Defaulted constructor.
RefCounted
inline noexcept
inline RefCounted(const RefCounted &) noexceptDefined in src/base/include/icy/memory.h:61
operator=
inline noexcept
inline RefCounted & operator=(const RefCounted &) noexceptDefined in src/base/include/icy/memory.h:62
addRef
const inline noexcept
inline void addRef() const noexceptDefined in src/base/include/icy/memory.h:65
Increments the reference count. Called by IntrusivePtr on acquisition.
releaseRef
const inline noexcept
inline bool releaseRef() const noexceptDefined in src/base/include/icy/memory.h:69
Decrements the reference count.
Returns
true if the count reached zero (caller should delete the object).
refCount
const inline noexcept
inline int refCount() const noexceptDefined in src/base/include/icy/memory.h:73
Returns the current reference count.
Returns
Current reference count.
Protected Methods
| Return | Name | Description |
|---|---|---|
~RefCounted | Defaulted destructor. |
~RefCounted
~RefCounted() = defaultDefined in src/base/include/icy/memory.h:76
Defaulted destructor.
Private Attributes
| Return | Name | Description |
|---|---|---|
int | _refCount |
_refCount
int _refCount = 0