Home
Base module

RefCounted

Base class for intrusive reference counting.

RefCounted

#include <icy/memory.h>
template<typename T>
class RefCounted

Defined in src/base/include/icy/memory.h:57

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, then use IntrusivePtr instead of std::shared_ptr.

List of all members

NameKindOwner
RefCountedfunctionDeclared here
RefCountedfunctionDeclared here
operator=functionDeclared here
addReffunctionDeclared here
releaseReffunctionDeclared here
refCountfunctionDeclared here
~RefCountedfunctionDeclared here
_refCountvariableDeclared here

Public Methods

ReturnNameDescription
RefCountedDefaulted constructor.
RefCounted inline noexcept
voidaddRef const inline noexceptIncrements the reference count. Called by IntrusivePtr on acquisition.
boolreleaseRef const inline noexceptDecrements the reference count.
intrefCount const inline noexceptReturns the current reference count.

RefCounted

RefCounted() = default

Defined in src/base/include/icy/memory.h:60

Defaulted constructor.


RefCounted

inline noexcept

inline RefCounted(const RefCounted &) noexcept

Defined in src/base/include/icy/memory.h:61


addRef

const inline noexcept

inline void addRef() const noexcept

Defined 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 noexcept

Defined 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 noexcept

Defined in src/base/include/icy/memory.h:73

Returns the current reference count.

Returns

Current reference count.

Private Attributes

ReturnNameDescription
int_refCount

_refCount

int _refCount = 0

Defined in src/base/include/icy/memory.h:79