senf::pool_alloc_mixin< Self > Class Template Reference

Mixin to assign pool allocator to a class. More...

#include <senf/Utils/pool_alloc_mixin.hh>

Classes

struct  pool
 Templated typedef for the pool used. More...
 

Static Public Member Functions

static void * operator new (size_t size)
 Operator new utilizing pool allocation. More...
 
static void operator delete (void *p, size_t size)
 Operator delete utilizing pool allocation. More...
 

Detailed Description

template<class Self>
class senf::pool_alloc_mixin< Self >

Mixin to assign pool allocator to a class.

This mixin will overload a classes operator new and operator delete so as to make the class use the Boost.Pool memory allocator by default. Using this allocator does however introduce a few restrictions:

  • The operator is defined for a fixed size. Therefore if you derive from the class you must not change it's size.
  • If you change the size of the class in a derived class you have to derive from pool_alloc_mixin again.

Usage:

class SomeClass
: public senf::pool_alloc_mixin<SomeClass>
{
// ...
};
    \note pool_alloc_mixin uses the <a
        href="http://www.boost.org/doc/libs/release/libs/pool/doc/index.html">Boost.Pool</a> <i>singleton
        pool</i> interface with the tag <tt>pool_alloc_mixin_tag</tt>. This class is accessible
        via the <tt>pool</tt> member. Using this member, it is simple to call relevant pool
        functions, e.g. <tt>SomeClass::pool<>::release_memory()</tt>.

Definition at line 58 of file pool_alloc_mixin.hh.

Member Function Documentation

◆ operator delete()

template<class Self >
static void senf::pool_alloc_mixin< Self >::operator delete ( void *  p,
size_t  size 
)
static

Operator delete utilizing pool allocation.

◆ operator new()

template<class Self >
static void* senf::pool_alloc_mixin< Self >::operator new ( size_t  size)
static

Operator new utilizing pool allocation.


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