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

Base class for object with reference counter. More...

#include <ref_counted.h>

Inheritance diagram for roc::core::RefCounted< T, AllocationPolicy >:
Collaboration diagram for roc::core::RefCounted< T, AllocationPolicy >:

Public Member Functions

 RefCounted ()
 Initialize. More...
 
 RefCounted (const AllocationPolicy &policy)
 Initialize. More...
 
int getref () const
 Get reference counter. More...
 
void incref () const
 Increment reference counter. More...
 
void decref () const
 Decrement reference counter. More...
 

Detailed Description

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

Base class for object with reference counter.

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

Template Parameters
Tdefines the derived class.
AllocationPolicydefines destroy policy.

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

Inherits AllocationPolicy to make its methods and state available in the derived class. E.g., PoolAllocation policy holds a reference to the pool and uses it to release the object.

Thread-safe.

Definition at line 39 of file ref_counted.h.

Constructor & Destructor Documentation

◆ RefCounted() [1/2]

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

Initialize.

Definition at line 43 of file ref_counted.h.

◆ RefCounted() [2/2]

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

Initialize.

Definition at line 48 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 65 of file ref_counted.h.

◆ getref()

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

Get reference counter.

Definition at line 53 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 58 of file ref_counted.h.


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