Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Loading...
Searching...
No Matches
roc::core::RefCounted< T, AllocationPolicy > Class Template Reference

Base class for reference counted object. More...

#include <ref_counted.h>

Inheritance diagram for roc::core::RefCounted< T, AllocationPolicy >:
roc::core::NonCopyable< RefCounted< T, AllocationPolicy > > roc::core::Buffer< sample_t > roc::core::Buffer< uint8_t > roc::core::Buffer< audio::sample_t >

Public Member Functions

 RefCounted ()
 Initialization with default allocation policy.
 
 RefCounted (const AllocationPolicy &policy)
 Initialization with arbitrary allocation policy.
 
long getref () const
 Get reference counter.
 
void incref () const
 Increment reference counter.
 
void decref () const
 Decrement reference counter.
 

Detailed Description

template<class T, class AllocationPolicy>
class roc::core::RefCounted< T, AllocationPolicy >

Base class for reference counted object.

Allows to increment and decrement reference counter. When the counter reaches zero, the object is automatically destroyed.

Template Parameters
Tdefines the derived class.
AllocationPolicydefies destroy policy.

When reference counter becomes zero, AllocationPolicy::destroy() is invoked by RefCounted to destroy itself.

Inherits AllocationPolicy to make its methods available in the derived class.

Thread-safe.

Definition at line 38 of file ref_counted.h.

Constructor & Destructor Documentation

◆ RefCounted() [1/2]

template<class T , class AllocationPolicy >
roc::core::RefCounted< T, AllocationPolicy >::RefCounted ( )
inline

Initialization with default allocation policy.

Definition at line 42 of file ref_counted.h.

◆ RefCounted() [2/2]

template<class T , class AllocationPolicy >
roc::core::RefCounted< T, AllocationPolicy >::RefCounted ( const AllocationPolicy &  policy)
inlineexplicit

Initialization with arbitrary allocation policy.

Definition at line 48 of file ref_counted.h.

◆ ~RefCounted()

template<class T , class AllocationPolicy >
roc::core::RefCounted< T, AllocationPolicy >::~RefCounted ( )
inline

Definition at line 53 of file ref_counted.h.

Member Function Documentation

◆ decref()

template<class T , class AllocationPolicy >
void roc::core::RefCounted< T, AllocationPolicy >::decref ( ) const
inline

Decrement reference counter.

Remarks
Destroys itself if reference counter becomes zero.

Definition at line 78 of file ref_counted.h.

◆ getref()

template<class T , class AllocationPolicy >
long roc::core::RefCounted< T, AllocationPolicy >::getref ( ) const
inline

Get reference counter.

Definition at line 62 of file ref_counted.h.

◆ incref()

template<class T , class AllocationPolicy >
void roc::core::RefCounted< T, AllocationPolicy >::incref ( ) const
inline

Increment reference counter.

Definition at line 67 of file ref_counted.h.


The documentation for this class was generated from the following file: