Click
Loading...
Searching...
No Matches
Public Member Functions | List of all members
MemoryPool< T > Class Template Reference

Template for memory pools. More...

#include <memorypool.hh>

Public Member Functions

 MemoryPool ()
 Construct an empty MemoryPool.
 
 MemoryPool (unsigned int initialSize)
 Construct a MemoryPool.
 
 ~MemoryPool ()
 Destruct the memory pool.
 
void initialize (unsigned int initialSize)
 Initialize the MemoryPool.
 
T * getMemory ()
 Obtain memory from the memory pool.
 
void releaseMemory (T *p)
 Release memory and put it back in the pool.
 

Detailed Description

template<typename T>
class MemoryPool< T >

Template for memory pools.

This template is used to create memory pools that can be used to achieve fast memory allocation. It is not multi-thread safe, but can be duplicated per-thread iif objects are always released on the same core they were allocated.

Constructor & Destructor Documentation

◆ MemoryPool() [1/2]

template<typename T >
MemoryPool< T >::MemoryPool ( )
inline

Construct an empty MemoryPool.

◆ MemoryPool() [2/2]

template<typename T >
MemoryPool< T >::MemoryPool ( unsigned int  initialSize)
inline

Construct a MemoryPool.

Parameters
initialSizeThe initial number of elements in the pool

◆ ~MemoryPool()

template<typename T >
MemoryPool< T >::~MemoryPool ( )
inline

Destruct the memory pool.

Member Function Documentation

◆ initialize()

template<typename T >
void MemoryPool< T >::initialize ( unsigned int  initialSize)
inline

Initialize the MemoryPool.

Parameters
initialSizeThe initial number of elements in the pool

◆ getMemory()

template<typename T >
T * MemoryPool< T >::getMemory ( )
inline

Obtain memory from the memory pool.

Returns
A pointer to an object of type T

◆ releaseMemory()

template<typename T >
void MemoryPool< T >::releaseMemory ( T *  p)
inline

Release memory and put it back in the pool.

Parameters
pPointer to the object of type T

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