Header file for the `static' memory pool. More...
#include <new>
#include <stdexcept>
#include <string>
#include <vector>
#include <assert.h>
#include <stddef.h>
#include "_nvwa.h"
#include "c++11.h"
#include "class_level_lock.h"
#include "mem_pool_base.h"
Go to the source code of this file.
Classes | |
class | nvwa::static_mem_pool_set |
Singleton class to maintain a set of existing instantiations of static_mem_pool. More... | |
class | nvwa::static_mem_pool< _Sz, _Gid > |
Singleton class template to manage the allocation/deallocation of memory blocks of one specific size. More... | |
Namespaces | |
namespace | nvwa |
Defines | |
#define | _STATIC_MEM_POOL_TRACE(_Lck, _Msg) ((void)0) |
#define | DECLARE_STATIC_MEM_POOL(_Cls) |
Declares the normal (throwing) allocation and deallocation functions. | |
#define | DECLARE_STATIC_MEM_POOL__NOTHROW(_Cls) |
Declares the nothrow allocation and deallocation functions. | |
#define | DECLARE_STATIC_MEM_POOL_GROUPED(_Cls, _Gid) |
Declares the normal (throwing) allocation and deallocation functions. | |
#define | DECLARE_STATIC_MEM_POOL_GROUPED__NOTHROW(_Cls, _Gid) |
Declares the nothrow allocation and deallocation functions. |
Header file for the `static' memory pool.
#define _STATIC_MEM_POOL_TRACE | ( | _Lck, | |||
_Msg | ) | ((void)0) |
#define DECLARE_STATIC_MEM_POOL | ( | _Cls | ) |
public: \ static void* operator new(size_t size) \ { \ assert(size == sizeof(_Cls)); \ void* ptr; \ ptr = NVWA::static_mem_pool<sizeof(_Cls)>:: \ instance_known().allocate(); \ if (ptr == NULL) \ throw std::bad_alloc(); \ return ptr; \ } \ static void operator delete(void* ptr) \ { \ if (ptr) \ NVWA::static_mem_pool<sizeof(_Cls)>:: \ instance_known().deallocate(ptr); \ }
Declares the normal (throwing) allocation and deallocation functions.
This macro uses the default group.
_Cls | class to use the static_mem_pool |
#define DECLARE_STATIC_MEM_POOL__NOTHROW | ( | _Cls | ) |
public: \ static void* operator new(size_t size) _NOEXCEPT \ { \ assert(size == sizeof(_Cls)); \ return NVWA::static_mem_pool<sizeof(_Cls)>:: \ instance_known().allocate(); \ } \ static void operator delete(void* ptr) \ { \ if (ptr) \ NVWA::static_mem_pool<sizeof(_Cls)>:: \ instance_known().deallocate(ptr); \ }
Declares the nothrow allocation and deallocation functions.
This macro uses the default group.
_Cls | class to use the static_mem_pool |
#define DECLARE_STATIC_MEM_POOL_GROUPED | ( | _Cls, | |||
_Gid | ) |
public: \ static void* operator new(size_t size) \ { \ assert(size == sizeof(_Cls)); \ void* ptr; \ ptr = NVWA::static_mem_pool<sizeof(_Cls), (_Gid)>:: \ instance_known().allocate(); \ if (ptr == NULL) \ throw std::bad_alloc(); \ return ptr; \ } \ static void operator delete(void* ptr) \ { \ if (ptr) \ NVWA::static_mem_pool<sizeof(_Cls), (_Gid)>:: \ instance_known().deallocate(ptr); \ }
Declares the normal (throwing) allocation and deallocation functions.
Users need to specify a group ID.
_Cls | class to use the static_mem_pool | |
_Gid | group ID (negative to protect multi-threaded access) |
#define DECLARE_STATIC_MEM_POOL_GROUPED__NOTHROW | ( | _Cls, | |||
_Gid | ) |
public: \ static void* operator new(size_t size) _NOEXCEPT \ { \ assert(size == sizeof(_Cls)); \ return NVWA::static_mem_pool<sizeof(_Cls), (_Gid)>:: \ instance_known().allocate(); \ } \ static void operator delete(void* ptr) \ { \ if (ptr) \ NVWA::static_mem_pool<sizeof(_Cls), (_Gid)>:: \ instance_known().deallocate(ptr); \ }
Declares the nothrow allocation and deallocation functions.
Users need to specify a group ID.
_Cls | class to use the static_mem_pool | |
_Gid | group ID (negative to protect multi-threaded access) |