Sacado Package Browser (Single Doxygen Collection)  Version of the Day
Classes | Public Member Functions | Protected Attributes | Private Member Functions | List of all members
Sacado::Fad::MemPool Class Reference

Memory pool. More...

#include <Sacado_Fad_MemPool.hpp>

Classes

struct  Chunk
 Represents a memory chunk. More...
 
struct  Link
 Represents a memory element. More...
 

Public Member Functions

 MemPool (unsigned int elem_size, unsigned int n_elem, unsigned int pre_alloc=0)
 Constructor. elem_size is the size of elements, n_elem is the number of elements per chunk. pre_alloc is the number of chunks to pre-allocate. More...
 
 ~MemPool ()
 Destructor. More...
 
void * alloc ()
 Allocate a new element. More...
 
void free (void *b)
 Free an element. More...
 
unsigned int numChunks () const
 Return number of allocated chunks. More...
 

Protected Attributes

const unsigned int esize
 Size of elements in a chunk. More...
 
const unsigned int n
 Number of elements per chunk. More...
 
const unsigned int csize
 Size of memory chunks. More...
 
Chunk * chunks
 Pointer to memory chunks. More...
 
Link * head
 Pointer to first free link. More...
 
unsigned int num_chunks
 Number of allocated chunks. More...
 

Private Member Functions

 MemPool (const MemPool &)
 Private to prohibit copying. More...
 
MemPool & operator= (const MemPool &)
 Private to prohibit copying. More...
 
void grow ()
 Allocate a new chunk. More...
 

Detailed Description

Memory pool.

Definition at line 40 of file Sacado_Fad_MemPool.hpp.

Constructor & Destructor Documentation

◆ MemPool() [1/2]

Sacado::Fad::MemPool::MemPool ( unsigned int  elem_size,
unsigned int  n_elem,
unsigned int  pre_alloc = 0 
)
inline

Constructor. elem_size is the size of elements, n_elem is the number of elements per chunk. pre_alloc is the number of chunks to pre-allocate.

Definition at line 35 of file Sacado_Fad_MemPoolImp.hpp.

◆ ~MemPool()

Sacado::Fad::MemPool::~MemPool ( )
inline

Destructor.

Definition at line 51 of file Sacado_Fad_MemPoolImp.hpp.

◆ MemPool() [2/2]

Sacado::Fad::MemPool::MemPool ( const MemPool &  )
private

Private to prohibit copying.

Member Function Documentation

◆ alloc()

void * Sacado::Fad::MemPool::alloc ( )
inline

Allocate a new element.

Definition at line 62 of file Sacado_Fad_MemPoolImp.hpp.

◆ free()

void Sacado::Fad::MemPool::free ( void *  b)
inline

Free an element.

Definition at line 73 of file Sacado_Fad_MemPoolImp.hpp.

◆ numChunks()

unsigned int Sacado::Fad::MemPool::numChunks ( ) const
inline

Return number of allocated chunks.

Definition at line 62 of file Sacado_Fad_MemPool.hpp.

◆ operator=()

MemPool& Sacado::Fad::MemPool::operator= ( const MemPool &  )
private

Private to prohibit copying.

◆ grow()

void Sacado::Fad::MemPool::grow ( )
inlineprivate

Allocate a new chunk.

Definition at line 83 of file Sacado_Fad_MemPoolImp.hpp.

Member Data Documentation

◆ esize

const unsigned int Sacado::Fad::MemPool::esize
protected

Size of elements in a chunk.

Definition at line 90 of file Sacado_Fad_MemPool.hpp.

◆ n

const unsigned int Sacado::Fad::MemPool::n
protected

Number of elements per chunk.

Definition at line 93 of file Sacado_Fad_MemPool.hpp.

◆ csize

const unsigned int Sacado::Fad::MemPool::csize
protected

Size of memory chunks.

Definition at line 96 of file Sacado_Fad_MemPool.hpp.

◆ chunks

Chunk* Sacado::Fad::MemPool::chunks
protected

Pointer to memory chunks.

Definition at line 99 of file Sacado_Fad_MemPool.hpp.

◆ head

Link* Sacado::Fad::MemPool::head
protected

Pointer to first free link.

Definition at line 102 of file Sacado_Fad_MemPool.hpp.

◆ num_chunks

unsigned int Sacado::Fad::MemPool::num_chunks
protected

Number of allocated chunks.

Definition at line 105 of file Sacado_Fad_MemPool.hpp.


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