class _Cls) definitions
Definition in file fixed_mem_pool.h.
#include <new>
#include <assert.h>
#include <stdlib.h>
#include "class_level_lock.h"
#include "mem_pool_base.h"
Go to the source code of this file.
Data Structures | |
| class | fixed_mem_pool< _Tp > |
Defines | |
| #define | DECLARE_FIXED_MEM_POOL(_Cls) |
| #define | DECLARE_FIXED_MEM_POOL__NOTHROW(_Cls) |
| #define | DECLARE_FIXED_MEM_POOL__THROW_NOCHECK(_Cls) |
| #define | MEM_POOL_ALIGNMENT 4 |
| #define DECLARE_FIXED_MEM_POOL | ( | _Cls | ) |
Value:
public: \ static void* operator new(size_t __size) \ { \ assert(__size == sizeof(_Cls)); \ if (void* __ptr = fixed_mem_pool<_Cls>::allocate()) \ return __ptr; \ else \ throw std::bad_alloc(); \ } \ static void operator delete(void* __ptr) \ { \ if (__ptr != NULL) \ fixed_mem_pool<_Cls>::deallocate(__ptr); \ }
| _Cls | class to use the fixed_mem_pool |
NULL, but requires more discipline on the programmer's side. Definition at line 252 of file fixed_mem_pool.h.
| #define DECLARE_FIXED_MEM_POOL__NOTHROW | ( | _Cls | ) |
Value:
public: \ static void* operator new(size_t __size) throw() \ { \ assert(__size == sizeof(_Cls)); \ return fixed_mem_pool<_Cls>::allocate(); \ } \ static void operator delete(void* __ptr) \ { \ if (__ptr != NULL) \ fixed_mem_pool<_Cls>::deallocate(__ptr); \ }
| _Cls | class to use the fixed_mem_pool |
Definition at line 274 of file fixed_mem_pool.h.
| #define DECLARE_FIXED_MEM_POOL__THROW_NOCHECK | ( | _Cls | ) |
Value:
public: \ static void* operator new(size_t __size) \ { \ assert(__size == sizeof(_Cls)); \ return fixed_mem_pool<_Cls>::allocate(); \ } \ static void operator delete(void* __ptr) \ { \ if (__ptr != NULL) \ fixed_mem_pool<_Cls>::deallocate(__ptr); \ }
N.B. Using this macro requires users to explicitly specialize fixed_mem_pool::bad_alloc_handler so that it shall never return false (it may throw exceptions, say, std::bad_alloc, or simply abort). Otherwise a segmentation fault might occur (instead of returning a NULL pointer).
| _Cls | class to use the fixed_mem_pool |
Definition at line 299 of file fixed_mem_pool.h.
| #define MEM_POOL_ALIGNMENT 4 |
Defines the alignment of memory blocks.
Definition at line 66 of file fixed_mem_pool.h.
Referenced by fixed_mem_pool< _Tp >::_S_align().
1.5.6