Proton  1.1.1
Make porting easy from Python to C++11
proton::smart_allocator< T, pool_tag > Class Template Reference

An extended allocator using memory pool. More...

#include <proton/pool.hpp>

List of all members.

Static Public Member Functions

static void confiscate (void *p)
 Free a memory block not dependable on T.
static void * duplicate (void *p)
 Free a memory block not dependable on T.

Detailed Description

template<class T, typename pool_tag = tmp_pool>
class proton::smart_allocator< T, pool_tag >

An extended allocator using memory pool.

Beside normal functions of std::allocator, smart_allocator also supports confiscate() and duplicate(), while confiscate(),duplicate() and allocate() must be static in smart_allocator. confiscate() is a general free function to deallocate memory blocks not dependable on T. duplicate() is a function to allocate a new memory block which size is the same as an given allocated block.

Definition at line 356 of file pool.hpp.


Member Function Documentation

template<class T , typename pool_tag = tmp_pool>
static void proton::smart_allocator< T, pool_tag >::confiscate ( void *  p)
inlinestatic

Free a memory block not dependable on T.

Different with deallocate(), confiscate() doesn't depend on type T information. confiscate() CAN safely free any pointer to memory blocks allocated by the same template of allocator, no matter what T is.

Parameters:
ppointer to the memory block to be freed

Definition at line 421 of file pool.hpp.

template<class T , typename pool_tag = tmp_pool>
static void* proton::smart_allocator< T, pool_tag >::duplicate ( void *  p)
inlinestatic

Free a memory block not dependable on T.

Different with deallocate(), confiscate() doesn't depend on type T information. confiscate() CAN safely free any pointer to memory blocks allocated by the same template of allocator, no matter what T is.

Parameters:
ppointer to the memory block to be freed

Definition at line 432 of file pool.hpp.


The documentation for this class was generated from the following file: