QxOrm  1.5.0
C++ Object Relational Mapping library
qx::memory::fixed_mem_pool< _Tp > Class Template Reference

#include <fixed_mem_pool.h>

List of all members.

Public Types

typedef class_level_lock
< fixed_mem_pool< _Tp >
>::lock 
lock

Static Public Member Functions

static void * allocate ()
static void deallocate (void *)
static bool initialize (size_t __size)
static int deinitialize ()
static int get_alloc_count ()
static bool is_initialized ()

Static Protected Member Functions

static bool bad_alloc_handler ()

Static Private Member Functions

static size_t _S_align (size_t __size)

Static Private Attributes

static void * _S_mem_pool_ptr = NULL
static void * _S_first_avail_ptr = NULL
static int _S_alloc_cnt = 0

Detailed Description

template<class _Tp>
class qx::memory::fixed_mem_pool< _Tp >

Class template to manipulate a fixed-size memory pool. Please notice that only allocate and deallocate are protected by a lock.

Parameters:
_Tpclass to use the fixed_mem_pool

Definition at line 88 of file fixed_mem_pool.h.


Member Typedef Documentation

template<class _Tp >
typedef class_level_lock<fixed_mem_pool<_Tp> >::lock qx::memory::fixed_mem_pool< _Tp >::lock

Definition at line 91 of file fixed_mem_pool.h.


Member Function Documentation

template<class _Tp >
size_t qx::memory::fixed_mem_pool< _Tp >::_S_align ( size_t  __size) [inline, static, private]

Aligns the memory block size.

Parameters:
__sizesize to be aligned
Returns:
aligned value of __size

Definition at line 248 of file fixed_mem_pool.h.

template<class _Tp >
void * qx::memory::fixed_mem_pool< _Tp >::allocate ( ) [inline, static]

Allocates a memory block from the memory pool.

Returns:
pointer to the allocated memory block

Definition at line 125 of file fixed_mem_pool.h.

template<class _Tp >
bool qx::memory::fixed_mem_pool< _Tp >::bad_alloc_handler ( ) [static, protected]

Bad allocation handler. Called when there are no memory blocks available in the memory pool. If this function returns false (default behaviour if not explicitly specialized), it indicates that it can do nothing and allocate() should return NULL; if this function returns true, it indicates that it has freed some memory blocks and allocate() should try allocating again.

Definition at line 236 of file fixed_mem_pool.h.

template<class _Tp >
void qx::memory::fixed_mem_pool< _Tp >::deallocate ( void *  __block_ptr) [inline, static]

Deallocates a memory block and returns it to the memory pool.

Parameters:
__block_ptrpointer to the memory block to return

Definition at line 148 of file fixed_mem_pool.h.

template<class _Tp >
int qx::memory::fixed_mem_pool< _Tp >::deinitialize ( ) [static]

Deinitializes the memory pool.

Returns:
0 if all memory blocks are returned and the memory pool successfully freed; or a non-zero value indicating number of memory blocks still in allocation

Definition at line 194 of file fixed_mem_pool.h.

template<class _Tp >
int qx::memory::fixed_mem_pool< _Tp >::get_alloc_count ( ) [inline, static]

Gets the allocation count.

Returns:
the number of memory blocks still in allocation

Definition at line 211 of file fixed_mem_pool.h.

template<class _Tp >
bool qx::memory::fixed_mem_pool< _Tp >::initialize ( size_t  __size) [static]

Initializes the memory pool.

Parameters:
__sizenumber of memory blocks to put in the memory pool
Returns:
true if successful; false if memory insufficient

Definition at line 166 of file fixed_mem_pool.h.

template<class _Tp >
bool qx::memory::fixed_mem_pool< _Tp >::is_initialized ( ) [inline, static]

Is the memory pool initialized?

Returns:
true if it is successfully initialized; false otherwise

Definition at line 222 of file fixed_mem_pool.h.


Member Data Documentation

template<class _Tp >
int qx::memory::fixed_mem_pool< _Tp >::_S_alloc_cnt = 0 [static, private]

Count of allocations.

Definition at line 104 of file fixed_mem_pool.h.

template<class _Tp >
void * qx::memory::fixed_mem_pool< _Tp >::_S_first_avail_ptr = NULL [static, private]

Pointer to the first available memory block.

Definition at line 103 of file fixed_mem_pool.h.

template<class _Tp >
void * qx::memory::fixed_mem_pool< _Tp >::_S_mem_pool_ptr = NULL [static, private]

Pointer to the allocated chunk of memory.

Definition at line 102 of file fixed_mem_pool.h.


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