static_mem_pool.h File Reference

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"
Include dependency graph for static_mem_pool.h:
This graph shows which files directly or indirectly include this file:

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.

Detailed Description

Header file for the `static' memory pool.

Date:
2013-10-06

Define Documentation

#define _STATIC_MEM_POOL_TRACE ( _Lck,
_Msg   )     ((void)0)
#define DECLARE_STATIC_MEM_POOL ( _Cls   ) 
Value:
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.

Parameters:
_Cls class to use the static_mem_pool
See also:
DECLARE_STATIC_MEM_POOL__NOTHROW
DECLARE_STATIC_MEM_POOL_GROUPED
DECLARE_STATIC_MEM_POOL_GROUPED__NOTHROW
#define DECLARE_STATIC_MEM_POOL__NOTHROW ( _Cls   ) 
Value:
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.

Parameters:
_Cls class to use the static_mem_pool
See also:
DECLARE_STATIC_MEM_POOL
DECLARE_STATIC_MEM_POOL_GROUPED
DECLARE_STATIC_MEM_POOL_GROUPED__NOTHROW
#define DECLARE_STATIC_MEM_POOL_GROUPED ( _Cls,
_Gid   ) 
Value:
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.

Parameters:
_Cls class to use the static_mem_pool
_Gid group ID (negative to protect multi-threaded access)
See also:
DECLARE_STATIC_MEM_POOL
DECLARE_STATIC_MEM_POOL__NOTHROW
DECLARE_STATIC_MEM_POOL_GROUPED__NOTHROW
#define DECLARE_STATIC_MEM_POOL_GROUPED__NOTHROW ( _Cls,
_Gid   ) 
Value:
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.

Parameters:
_Cls class to use the static_mem_pool
_Gid group ID (negative to protect multi-threaded access)
See also:
DECLARE_STATIC_MEM_POOL
DECLARE_STATIC_MEM_POOL__NOTHROW
DECLARE_STATIC_MEM_POOL_GROUPED
 All Classes Namespaces Files Functions Variables Typedefs Friends Defines

Generated by  doxygen 1.6.2