QxOrm
1.5.0
C++ Object Relational Mapping library
|
#include <static_mem_pool.h>
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_pool & | operator= (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 |
Singleton class template to manage the allocation/deallocation of memory blocks of one specific size.
_Sz | size of elements in the static_mem_pool |
_Gid | group 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.
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.
qx::memory::static_mem_pool< _Sz, _Gid >::static_mem_pool | ( | ) | [inline, private] |
Definition at line 195 of file static_mem_pool.h.
qx::memory::static_mem_pool< _Sz, _Gid >::~static_mem_pool | ( | ) | [inline, private] |
Definition at line 200 of file static_mem_pool.h.
qx::memory::static_mem_pool< _Sz, _Gid >::static_mem_pool | ( | const static_mem_pool< _Sz, _Gid > & | ) | [private] |
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.
return qx::memory::static_mem_pool< _Sz, _Gid >::_S_alloc_sys | ( | _S_align(_Sz) | ) | [private] |
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.
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.
void qx::memory::static_mem_pool< _Sz, _Gid >::deallocate | ( | void * | __ptr | ) | [inline, private] |
Deallocates memory by putting the memory block into the pool.
__ptr | pointer to memory to be deallocated |
Definition at line 184 of file static_mem_pool.h.
const static_mem_pool& qx::memory::static_mem_pool< _Sz, _Gid >::operator= | ( | const static_mem_pool< _Sz, _Gid > & | ) | [private] |
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.
return qx::memory::static_mem_pool< _Sz, _Gid >::__result [private] |
Definition at line 174 of file static_mem_pool.h.
bool qx::memory::static_mem_pool< _Sz, _Gid >::_S_destroyed = false [static, private] |
Definition at line 228 of file static_mem_pool.h.
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.
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.