libMesh
Classes | Public Member Functions | Static Public Member Functions | List of all members
libMesh::FastPoolAllocator< T > Class Template Reference

An allocator which can be used in standard containers. More...

#include <pool_allocator.h>

Inheritance diagram for libMesh::FastPoolAllocator< T >:
[legend]

Classes

struct  rebind
 Methods required for copy construction of containers using this allocator. More...
 

Public Member Functions

 FastPoolAllocator ()
 
template<typename U >
 FastPoolAllocator (const FastPoolAllocator< U > &o)
 
 FastPoolAllocator ()
 
template<typename U >
 FastPoolAllocator (const FastPoolAllocator< U > &o)
 

Static Public Member Functions

static bool release_memory ()
 Frees every memory block that doesn't have any allocated chunks. More...
 
static bool purge_memory ()
 Frees every memory block. More...
 
static bool release_memory ()
 Frees every memory block that doesn't have any allocated chunks. More...
 
static bool purge_memory ()
 Frees every memory block. More...
 

Detailed Description

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

An allocator which can be used in standard containers.

Uses pool-based memory allocation to efficiently allocate many small objects.

Note
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 Boost-derived allocator that can be used with std::containers.

A wrapper for std::allocator<> when Boost is not available.

Author
Benjamin S. Kirk
Date
2011 FastPoolAllocator is std::allocator when Boost is not available.

Definition at line 112 of file pool_allocator.h.

Constructor & Destructor Documentation

◆ FastPoolAllocator() [1/4]

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

Definition at line 125 of file pool_allocator.h.

125  :
126  boost::fast_pool_allocator<T>()
127  {}

◆ FastPoolAllocator() [2/4]

template<typename T>
template<typename U >
libMesh::FastPoolAllocator< T >::FastPoolAllocator ( const FastPoolAllocator< U > &  o)
inline

Definition at line 130 of file pool_allocator.h.

130  :
131  boost::fast_pool_allocator<T>(o)
132  {}

◆ FastPoolAllocator() [3/4]

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

Definition at line 227 of file pool_allocator.h.

227  :
228  std::allocator<T>()
229  {}

◆ FastPoolAllocator() [4/4]

template<typename T>
template<typename U >
libMesh::FastPoolAllocator< T >::FastPoolAllocator ( const FastPoolAllocator< U > &  o)
inline

Definition at line 232 of file pool_allocator.h.

232  :
233  std::allocator<T>(o)
234  {}

Member Function Documentation

◆ purge_memory() [1/2]

template<typename T>
static bool libMesh::FastPoolAllocator< 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 150 of file pool_allocator.h.

151  {
152  return boost::singleton_pool<boost::fast_pool_allocator_tag, sizeof(T)>::purge_memory();
153  }

◆ purge_memory() [2/2]

template<typename T>
static bool libMesh::FastPoolAllocator< 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 248 of file pool_allocator.h.

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

◆ release_memory() [1/2]

template<typename T>
static bool libMesh::FastPoolAllocator< 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 139 of file pool_allocator.h.

140  {
141  return boost::singleton_pool<boost::fast_pool_allocator_tag, sizeof(T)>::release_memory();
142  }

◆ release_memory() [2/2]

template<typename T>
static bool libMesh::FastPoolAllocator< 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 240 of file pool_allocator.h.

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

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