Base module

RefCounted

Base class for intrusive reference counting.

#include <icy/memory.h>

template<typename T>
class RefCounted

Defined 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

ReturnNameDescription
RefCountedDefaulted constructor.
RefCounted inline noexcept
RefCounted &operator= 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


operator=

inline noexcept

inline RefCounted & operator=(const RefCounted &) noexcept

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


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.

Protected Methods

ReturnNameDescription
~RefCountedDefaulted destructor.

~RefCounted

~RefCounted() = default

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

Defaulted destructor.

Private Attributes

ReturnNameDescription
int_refCount

_refCount

int _refCount = 0

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