RefCounted
RefCounted
#include <icy/memory.h>Subclassed by:
PacketTransaction< Message >,Context< uv_pipe_t >,Context< uv_tcp_t >,Context< uv_udp_t >,Context< uv_idle_t >,Context< uv_process_t >,Context< uv_async_t >,Context< uv_timer_t >
Base class for intrusive reference counting.
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
Public Methods
| Return | Name | Description |
|---|---|---|
RefCounted | Defaulted constructor. | |
RefCounted inline | ||
void | addRef const inline | Increments the reference count. Called by IntrusivePtr on acquisition. |
bool | releaseRef const inline | Decrements the reference count. |
int | refCount const inline | Returns the current reference count. |
RefCounted
RefCounted() = defaultDefaulted constructor.
RefCounted
inline
inline RefCounted(const RefCounted &) noexceptaddRef
const inline
inline void addRef() const noexceptIncrements the reference count. Called by IntrusivePtr on acquisition.
releaseRef
const inline
inline bool releaseRef() const noexceptDecrements the reference count.
Returns
true if the count reached zero (caller should delete the object).
refCount
const inline
inline int refCount() const noexceptReturns the current reference count.
Returns
Current reference count.
Private Attributes
| Return | Name | Description |
|---|---|---|
int | _refCount |
_refCount
int _refCount = 0