QxOrm  1.5.0
C++ Object Relational Mapping library
qx::memory::static_mem_pool< _Sz, _Gid > Class Template Reference

#include <static_mem_pool.h>

Inheritance diagram for qx::memory::static_mem_pool< _Sz, _Gid >:
qx::memory::mem_pool_base

List of all members.

Private Types

typedef class_level_lock
< static_mem_pool< _Sz, _Gid >
,(_Gid< 0)>::lock lock;public:static
static_mem_pool &instance(){lock
__guard;if(!_S_instance_p){_S_instance_p=_S_create_instance();}return
*_S_instance_p;}static
static_mem_pool
&instance_known(){assert(_S_instance_p!=NULL);return
*_S_instance_p;}void *allocate(){{lock
__guard;if(_S_memory_block_p){void
*__result=_S_memory_block_p;_S_memory_block_p=_S_memory_block_p-> 
_M_next

Private Member Functions

return _S_alloc_sys (_S_align(_Sz))
void deallocate (void *__ptr)
virtual void recycle ()
 static_mem_pool ()
 ~static_mem_pool ()
 static_mem_pool (const static_mem_pool &)
const static_mem_pooloperator= (const static_mem_pool &)

Static Private Member Functions

static size_t _S_align (size_t __size)
static void * _S_alloc_sys (size_t __size)
static static_mem_pool_S_create_instance ()

Private Attributes

return __result

Static Private Attributes

static bool _S_destroyed = false
static static_mem_pool_S_instance_p = _S_create_instance()
static mem_pool_base::_Block_list_S_memory_block_p = NULL

Detailed Description

template<size_t _Sz, int _Gid = -1>
class qx::memory::static_mem_pool< _Sz, _Gid >

Singleton class template to manage the allocation/deallocation of memory blocks of one specific size.

Parameters:
_Szsize of elements in the static_mem_pool
_Gidgroup id of a static_mem_pool: if it is negative, simultaneous accesses to this static_mem_pool will be protected from each other; otherwise no protection is given

Definition at line 124 of file static_mem_pool.h.


Member Typedef Documentation

template<size_t _Sz, int _Gid = -1>
typedef class_level_lock<static_mem_pool<_Sz, _Gid>, (_Gid < 0)>::lock lock;public: static static_mem_pool& instance() { lock __guard; if (!_S_instance_p) { _S_instance_p = _S_create_instance(); } return *_S_instance_p; } static static_mem_pool& instance_known() { assert(_S_instance_p != NULL); return *_S_instance_p; } void* allocate() { { lock __guard; if (_S_memory_block_p) { void* __result = _S_memory_block_p; _S_memory_block_p = _S_memory_block_p-> qx::memory::static_mem_pool< _Sz, _Gid >::_M_next [private]

Definition at line 173 of file static_mem_pool.h.


Constructor & Destructor Documentation

template<size_t _Sz, int _Gid = -1>
qx::memory::static_mem_pool< _Sz, _Gid >::static_mem_pool ( ) [inline, private]

Definition at line 195 of file static_mem_pool.h.

template<size_t _Sz, int _Gid = -1>
qx::memory::static_mem_pool< _Sz, _Gid >::~static_mem_pool ( ) [inline, private]

Definition at line 200 of file static_mem_pool.h.

template<size_t _Sz, int _Gid = -1>
qx::memory::static_mem_pool< _Sz, _Gid >::static_mem_pool ( const static_mem_pool< _Sz, _Gid > &  ) [private]

Member Function Documentation

template<size_t _Sz, int _Gid = -1>
static size_t qx::memory::static_mem_pool< _Sz, _Gid >::_S_align ( size_t  __size) [inline, static, private]

Definition at line 221 of file static_mem_pool.h.

template<size_t _Sz, int _Gid = -1>
return qx::memory::static_mem_pool< _Sz, _Gid >::_S_alloc_sys ( _S_align(_Sz)  ) [private]
template<size_t _Sz, int _Gid>
void * qx::memory::static_mem_pool< _Sz, _Gid >::_S_alloc_sys ( size_t  __size) [static, private]

Definition at line 276 of file static_mem_pool.h.

template<size_t _Sz, int _Gid>
static_mem_pool< _Sz, _Gid > * qx::memory::static_mem_pool< _Sz, _Gid >::_S_create_instance ( ) [static, private]

Definition at line 289 of file static_mem_pool.h.

template<size_t _Sz, int _Gid = -1>
void qx::memory::static_mem_pool< _Sz, _Gid >::deallocate ( void *  __ptr) [inline, private]

Deallocates memory by putting the memory block into the pool.

Parameters:
__ptrpointer to memory to be deallocated

Definition at line 184 of file static_mem_pool.h.

template<size_t _Sz, int _Gid = -1>
const static_mem_pool& qx::memory::static_mem_pool< _Sz, _Gid >::operator= ( const static_mem_pool< _Sz, _Gid > &  ) [private]
template<size_t _Sz, int _Gid>
void qx::memory::static_mem_pool< _Sz, _Gid >::recycle ( ) [private, virtual]

Recycles half of the free memory blocks in the memory pool to the system. It is called when a memory request to the system (in other instances of the static memory pool) fails.

Implements qx::memory::mem_pool_base.

Definition at line 250 of file static_mem_pool.h.


Member Data Documentation

template<size_t _Sz, int _Gid = -1>
return qx::memory::static_mem_pool< _Sz, _Gid >::__result [private]

Definition at line 174 of file static_mem_pool.h.

template<size_t _Sz, int _Gid = -1>
bool qx::memory::static_mem_pool< _Sz, _Gid >::_S_destroyed = false [static, private]

Definition at line 228 of file static_mem_pool.h.

template<size_t _Sz, int _Gid = -1>
static_mem_pool< _Sz, _Gid > * qx::memory::static_mem_pool< _Sz, _Gid >::_S_instance_p = _S_create_instance() [static, private]

Definition at line 229 of file static_mem_pool.h.

template<size_t _Sz, int _Gid = -1>
mem_pool_base::_Block_list * qx::memory::static_mem_pool< _Sz, _Gid >::_S_memory_block_p = NULL [static, private]

Definition at line 230 of file static_mem_pool.h.


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