Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
roc::core::LimitedPool Class Reference

Decorator around IPool to make it memory limited. More...

#include <limited_pool.h>

Inheritance diagram for roc::core::LimitedPool:
Collaboration diagram for roc::core::LimitedPool:

Public Member Functions

 LimitedPool (IPool &pool, MemoryLimiter &memory_limiter)
 Initialize. More...
 
virtual size_t allocation_size () const
 Get size of the allocation per object. More...
 
virtual size_t object_size () const
 Get size of the object. More...
 
virtual ROC_ATTR_NODISCARD bool reserve (size_t n_objects)
 Reserve memory for given number of objects. More...
 
virtual void * allocate ()
 Allocate memory for an object, after checking with the memory limiter. More...
 
virtual void deallocate (void *memory)
 Return memory to pool, then update the memory limiter. More...
 
- Public Member Functions inherited from roc::core::IPool
template<class T >
void destroy_object (T &object)
 Destroy object and deallocate its memory. More...
 

Detailed Description

Decorator around IPool to make it memory limited.

Definition at line 23 of file limited_pool.h.

Constructor & Destructor Documentation

◆ LimitedPool()

roc::core::LimitedPool::LimitedPool ( IPool pool,
MemoryLimiter memory_limiter 
)

Initialize.

Member Function Documentation

◆ allocate()

virtual void* roc::core::LimitedPool::allocate ( )
virtual

Allocate memory for an object, after checking with the memory limiter.

Returns
pointer to a maximum aligned uninitialized memory for a new object or NULL if memory can't be allocated.

Implements roc::core::IPool.

◆ allocation_size()

virtual size_t roc::core::LimitedPool::allocation_size ( ) const
virtual

Get size of the allocation per object.

Implements roc::core::IPool.

◆ deallocate()

virtual void roc::core::LimitedPool::deallocate ( void *  memory)
virtual

Return memory to pool, then update the memory limiter.

Implements roc::core::IPool.

◆ object_size()

virtual size_t roc::core::LimitedPool::object_size ( ) const
virtual

Get size of the object.

Implements roc::core::IPool.

◆ reserve()

virtual ROC_ATTR_NODISCARD bool roc::core::LimitedPool::reserve ( size_t  n_objects)
virtual

Reserve memory for given number of objects.

Returns
false if allocation failed.

Implements roc::core::IPool.


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