libMesh::PoolAllocator< T > Class Template Reference

Boost-derived allocator that can be used with std::containers. More...

#include <pool_allocator.h>

Inheritance diagram for libMesh::PoolAllocator< T >:

Classes

struct  rebind
 

Public Member Functions

 PoolAllocator ()
 
 PoolAllocator (const PoolAllocator &o)
 
 PoolAllocator ()
 
 PoolAllocator (const PoolAllocator &o)
 

Static Public Member Functions

static bool release_memory ()
 
static bool purge_memory ()
 
static bool release_memory ()
 
static bool purge_memory ()
 

Detailed Description

template<typename T>
class libMesh::PoolAllocator< T >

Boost-derived allocator that can be used with std::containers.

PoolAllocator is std::allocator when Boost is not available.

An allocator which can be used in standard containers. Uses pool-based memory allocation to efficiently allocate many small objects. Note that object destruction returns memory to the pool rather than deallocate it. It must be explicitly deallocated prior to program termination.

Author
Benjamin S. Kirk
Date
2011

An allocator which can be used in standard containers. A wrapper for std::allocator<> when Boost is not available.

Author
Benjamin S. Kirk
Date
2011

Definition at line 51 of file pool_allocator.h.

Constructor & Destructor Documentation

template<typename T >
libMesh::PoolAllocator< T >::PoolAllocator ( )
inline

Definition at line 64 of file pool_allocator.h.

64  :
65  boost::pool_allocator<T>()
66  {}
template<typename T >
libMesh::PoolAllocator< T >::PoolAllocator ( const PoolAllocator< T > &  o)
inlineexplicit

Definition at line 68 of file pool_allocator.h.

68  :
69  boost::pool_allocator<T>(o)
70  {}
template<typename T >
libMesh::PoolAllocator< T >::PoolAllocator ( )
inline

Definition at line 170 of file pool_allocator.h.

170  :
171  std::allocator<T>()
172  {}
template<typename T >
libMesh::PoolAllocator< T >::PoolAllocator ( const PoolAllocator< T > &  o)
inlineexplicit

Definition at line 174 of file pool_allocator.h.

174  :
175  std::allocator<T>(o)
176  {}

Member Function Documentation

template<typename T >
static bool libMesh::PoolAllocator< T >::purge_memory ( )
inlinestatic

Frees every memory block. This function invalidates any pointers previously returned by allocation functions. Returns true if at least one memory block was freed.

Definition at line 85 of file pool_allocator.h.

86  {
87  return boost::singleton_pool<boost::pool_allocator_tag, sizeof(T)>::purge_memory();
88  }
template<typename T >
static bool libMesh::PoolAllocator< T >::purge_memory ( )
inlinestatic

Frees every memory block. This function invalidates any pointers previously returned by allocation functions. Returns true if at least one memory block was freed.

Definition at line 188 of file pool_allocator.h.

188 { /* no-op for std::allocator<> - already freed. */ return false; }
template<typename T >
static bool libMesh::PoolAllocator< T >::release_memory ( )
inlinestatic

Frees every memory block that doesn't have any allocated chunks. Returns true if at least one memory block was freed.

Definition at line 76 of file pool_allocator.h.

77  {
78  return boost::singleton_pool<boost::pool_allocator_tag, sizeof(T)>::release_memory();
79  }
template<typename T >
static bool libMesh::PoolAllocator< T >::release_memory ( )
inlinestatic

Frees every memory block that doesn't have any allocated chunks. Returns true if at least one memory block was freed.

Definition at line 182 of file pool_allocator.h.

182 { /* no-op for std::allocator<> - already freed. */ return false; }

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