41#ifndef _QX_MODE_RELEASE
42#if _QX_USE_MEM_LEAK_DETECTION
44#ifndef _STATIC_MEM_POOL_H
45#define _STATIC_MEM_POOL_H
61# if (defined(_MSC_VER) && _MSC_VER < 1300) \
62 || (defined(__BORLANDC__) && __BORLANDC__ < 0x600)
63# define __PRIVATE public
65# define __PRIVATE private
69# ifdef _STATIC_MEM_POOL_DEBUG
71# define _STATIC_MEM_POOL_TRACE(_Lck, _Msg) \
74 static_mem_pool_set::lock __guard; \
75 std::cerr << "static_mem_pool: " << _Msg << std::endl; \
77 std::cerr << "static_mem_pool: " << _Msg << std::endl; \
81# define _STATIC_MEM_POOL_TRACE(_Lck, _Msg) \
123template <
size_t _Sz,
int _Gid = -1>
186 assert(__ptr != NULL);
198 << _Gid <<
"> is created");
202#ifndef _QX_MODE_RELEASE
219 << _Gid <<
"> is destroyed");
237template <
size_t _Sz,
int _G
id>
bool
249template <
size_t _Sz,
int _G
id>
263 dealloc_sys(__temp_);
272 << _Gid <<
"> is recycled");
275template <
size_t _Sz,
int _G
id>
288template <
size_t _Sz,
int _G
id>
292 throw std::runtime_error(
"dead reference detected");
303 "Exception occurs in static_mem_pool_set::add");
314#define DECLARE_STATIC_MEM_POOL(_Cls) \
316 static void* operator new(size_t __size) \
318 assert(__size == sizeof(_Cls)); \
320 __ptr = static_mem_pool<sizeof(_Cls)>:: \
321 instance_known().allocate(); \
323 throw std::bad_alloc(); \
326 static void operator delete(void* __ptr) \
329 static_mem_pool<sizeof(_Cls)>:: \
330 instance_known().deallocate(__ptr); \
333#define DECLARE_STATIC_MEM_POOL__NOTHROW(_Cls) \
335 static void* operator new(size_t __size) throw() \
337 assert(__size == sizeof(_Cls)); \
338 return static_mem_pool<sizeof(_Cls)>:: \
339 instance_known().allocate(); \
341 static void operator delete(void* __ptr) \
344 static_mem_pool<sizeof(_Cls)>:: \
345 instance_known().deallocate(__ptr); \
348#define DECLARE_STATIC_MEM_POOL_GROUPED(_Cls, _Gid) \
350 static void* operator new(size_t __size) \
352 assert(__size == sizeof(_Cls)); \
354 __ptr = static_mem_pool<sizeof(_Cls), (_Gid)>:: \
355 instance_known().allocate(); \
357 throw std::bad_alloc(); \
360 static void operator delete(void* __ptr) \
363 static_mem_pool<sizeof(_Cls), (_Gid)>:: \
364 instance_known().deallocate(__ptr); \
367#define DECLARE_STATIC_MEM_POOL_GROUPED__NOTHROW(_Cls, _Gid) \
369 static void* operator new(size_t __size) throw() \
371 assert(__size == sizeof(_Cls)); \
372 return static_mem_pool<sizeof(_Cls), (_Gid)>:: \
373 instance_known().allocate(); \
375 static void operator delete(void* __ptr) \
378 static_mem_pool<sizeof(_Cls), (_Gid)>:: \
379 instance_known().deallocate(__ptr); \
383#define PREPARE_STATIC_MEM_POOL(_Cls) \
384 std::cerr << "PREPARE_STATIC_MEM_POOL is obsolete!\n";
387#define PREPARE_STATIC_MEM_POOL_GROUPED(_Cls, _Gid) \
388 std::cerr << "PREPARE_STATIC_MEM_POOL_GROUPED is obsolete!\n";
static void * alloc_sys(size_t __size)
static void dealloc_sys(void *__ptr)
static_mem_pool_set(const static_mem_pool_set &)
static static_mem_pool_set & instance()
const static_mem_pool_set & operator=(const static_mem_pool_set &)
container_type _M_memory_pool_set
class_level_lock< static_mem_pool_set >::lock lock
std::vector< mem_pool_base * > container_type
void add(mem_pool_base *__memory_pool_p)
static mem_pool_base::_Block_list * _S_memory_block_p
class_level_lock< static_mem_pool< _Sz, _Gid >,(_Gid< 0)>::lock lock
void deallocate(void *__ptr)
static static_mem_pool * _S_instance_p
static static_mem_pool * _S_create_instance()
static static_mem_pool & instance()
static_mem_pool(const static_mem_pool &)
static static_mem_pool & instance_known()
static size_t _S_align(size_t __size)
const static_mem_pool & operator=(const static_mem_pool &)
static void * _S_alloc_sys(size_t __size)
Root namespace for all QxOrm library features.
#define _STATIC_MEM_POOL_TRACE(_Lck, _Msg)