Boost  v1.57.0
doxygen for www.boost.org
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
boost::fast_pool_allocator< T, UserAllocator, Mutex, NextSize, MaxSize > Singleton Reference

A C++ Standard Library conforming allocator geared towards allocating single chunks. More...

#include <poolfwd.hpp>

Classes

struct  rebind
 Nested class rebind allows for transformation from fast_pool_allocator<T> to fast_pool_allocator<U>. More...
 

Public Types

typedef T value_type
 
typedef UserAllocator user_allocator
 
typedef Mutex mutex
 
typedef value_typepointer
 
typedef const value_typeconst_pointer
 
typedef value_typereference
 
typedef const value_typeconst_reference
 
typedef pool< UserAllocator >
::size_type 
size_type
 
typedef pool< UserAllocator >
::difference_type 
difference_type
 

Public Member Functions

 BOOST_STATIC_CONSTANT (unsigned, next_size=NextSize)
 
 fast_pool_allocator ()
 
template<typename U >
 fast_pool_allocator (const fast_pool_allocator< U, UserAllocator, Mutex, NextSize, MaxSize > &)
 
void construct (const pointer ptr, const value_type &t)
 
void destroy (const pointer ptr)
 
bool operator== (const fast_pool_allocator &) const
 
bool operator!= (const fast_pool_allocator &) const
 

Static Public Member Functions

static pointer address (reference r)
 
static const_pointer address (const_reference s)
 
static size_type max_size ()
 
static pointer allocate (const size_type n)
 
static pointer allocate (const size_type n, const void *const)
 
static pointer allocate ()
 
static void deallocate (const pointer ptr, const size_type n)
 
static void deallocate (const pointer ptr)
 

Detailed Description

template<typename T, typename UserAllocator, typename Mutex, unsigned NextSize, unsigned MaxSize>
singleton boost::fast_pool_allocator< T, UserAllocator, Mutex, NextSize, MaxSize >

A C++ Standard Library conforming allocator geared towards allocating single chunks.

While class template pool_allocator is a more general-purpose solution geared towards efficiently servicing requests for any number of contiguous chunks, fast_pool_allocator is also a general-purpose solution, but is geared towards efficiently servicing requests for one chunk at a time; it will work for contiguous chunks, but not as well as pool_allocator.

If you are seriously concerned about performance, use fast_pool_allocator when dealing with containers such as std::list, and use pool_allocator when dealing with containers such as std::vector.

The template parameters are defined as follows:

T Type of object to allocate/deallocate.

UserAllocator. Defines the method that the underlying Pool will use to allocate memory from the system. See User Allocators for details.

Mutex Allows the user to determine the type of synchronization to be used on the underlying singleton_pool.

NextSize The value of this parameter is passed to the underlying Pool when it is created.

MaxSize Limit on the maximum size used.

Attention
The underlying singleton_pool used by the this allocator constructs a pool instance that is never freed. This means that memory allocated by the allocator can be still used after main() has completed, but may mean that some memory checking programs will complain about leaks.

Member Typedef Documentation

template<typename T , typename UserAllocator , typename Mutex , unsigned NextSize, unsigned MaxSize>
typedef const value_type* boost::fast_pool_allocator< T, UserAllocator, Mutex, NextSize, MaxSize >::const_pointer
template<typename T , typename UserAllocator , typename Mutex , unsigned NextSize, unsigned MaxSize>
typedef const value_type& boost::fast_pool_allocator< T, UserAllocator, Mutex, NextSize, MaxSize >::const_reference
template<typename T , typename UserAllocator , typename Mutex , unsigned NextSize, unsigned MaxSize>
typedef pool<UserAllocator>::difference_type boost::fast_pool_allocator< T, UserAllocator, Mutex, NextSize, MaxSize >::difference_type
template<typename T , typename UserAllocator , typename Mutex , unsigned NextSize, unsigned MaxSize>
typedef Mutex boost::fast_pool_allocator< T, UserAllocator, Mutex, NextSize, MaxSize >::mutex
template<typename T , typename UserAllocator , typename Mutex , unsigned NextSize, unsigned MaxSize>
typedef value_type* boost::fast_pool_allocator< T, UserAllocator, Mutex, NextSize, MaxSize >::pointer
template<typename T , typename UserAllocator , typename Mutex , unsigned NextSize, unsigned MaxSize>
typedef value_type& boost::fast_pool_allocator< T, UserAllocator, Mutex, NextSize, MaxSize >::reference
template<typename T , typename UserAllocator , typename Mutex , unsigned NextSize, unsigned MaxSize>
typedef pool<UserAllocator>::size_type boost::fast_pool_allocator< T, UserAllocator, Mutex, NextSize, MaxSize >::size_type
template<typename T , typename UserAllocator , typename Mutex , unsigned NextSize, unsigned MaxSize>
typedef UserAllocator boost::fast_pool_allocator< T, UserAllocator, Mutex, NextSize, MaxSize >::user_allocator
template<typename T , typename UserAllocator , typename Mutex , unsigned NextSize, unsigned MaxSize>
typedef T boost::fast_pool_allocator< T, UserAllocator, Mutex, NextSize, MaxSize >::value_type

Constructor & Destructor Documentation

template<typename T , typename UserAllocator , typename Mutex , unsigned NextSize, unsigned MaxSize>
boost::fast_pool_allocator< T, UserAllocator, Mutex, NextSize, MaxSize >::fast_pool_allocator ( )
inline

Ensures construction of the underlying singleton_pool IFF an instance of this allocator is constructed during global initialization. See ticket #2359 for a complete explanation at http://svn.boost.org/trac/boost/ticket/2359 .

References T.

template<typename T , typename UserAllocator , typename Mutex , unsigned NextSize, unsigned MaxSize>
template<typename U >
boost::fast_pool_allocator< T, UserAllocator, Mutex, NextSize, MaxSize >::fast_pool_allocator ( const fast_pool_allocator< U, UserAllocator, Mutex, NextSize, MaxSize > &  )
inline

Ensures construction of the underlying singleton_pool IFF an instance of this allocator is constructed during global initialization. See ticket #2359 for a complete explanation at http://svn.boost.org/trac/boost/ticket/2359 .

References T.

Member Function Documentation

template<typename T , typename UserAllocator , typename Mutex , unsigned NextSize, unsigned MaxSize>
static pointer boost::fast_pool_allocator< T, UserAllocator, Mutex, NextSize, MaxSize >::address ( reference  r)
inlinestatic
template<typename T , typename UserAllocator , typename Mutex , unsigned NextSize, unsigned MaxSize>
static const_pointer boost::fast_pool_allocator< T, UserAllocator, Mutex, NextSize, MaxSize >::address ( const_reference  s)
inlinestatic

References boost::asio::s.

template<typename T , typename UserAllocator , typename Mutex , unsigned NextSize, unsigned MaxSize>
static pointer boost::fast_pool_allocator< T, UserAllocator, Mutex, NextSize, MaxSize >::allocate ( const size_type  n)
inlinestatic

References T, and boost::throw_exception().

template<typename T , typename UserAllocator , typename Mutex , unsigned NextSize, unsigned MaxSize>
static pointer boost::fast_pool_allocator< T, UserAllocator, Mutex, NextSize, MaxSize >::allocate ( const size_type  n,
const void *  const 
)
inlinestatic
template<typename T , typename UserAllocator , typename Mutex , unsigned NextSize, unsigned MaxSize>
static pointer boost::fast_pool_allocator< T, UserAllocator, Mutex, NextSize, MaxSize >::allocate ( void  )
inlinestatic
template<typename T , typename UserAllocator , typename Mutex , unsigned NextSize, unsigned MaxSize>
boost::fast_pool_allocator< T, UserAllocator, Mutex, NextSize, MaxSize >::BOOST_STATIC_CONSTANT ( unsigned  ,
next_size  = NextSize 
)
template<typename T , typename UserAllocator , typename Mutex , unsigned NextSize, unsigned MaxSize>
void boost::fast_pool_allocator< T, UserAllocator, Mutex, NextSize, MaxSize >::construct ( const pointer  ptr,
const value_type t 
)
inline

References boost::python::ptr(), and T.

template<typename T , typename UserAllocator , typename Mutex , unsigned NextSize, unsigned MaxSize>
static void boost::fast_pool_allocator< T, UserAllocator, Mutex, NextSize, MaxSize >::deallocate ( const pointer  ptr,
const size_type  n 
)
inlinestatic

Deallocate memory.

References boost::python::ptr(), and T.

template<typename T , typename UserAllocator , typename Mutex , unsigned NextSize, unsigned MaxSize>
static void boost::fast_pool_allocator< T, UserAllocator, Mutex, NextSize, MaxSize >::deallocate ( const pointer  ptr)
inlinestatic

deallocate/free

References boost::python::ptr(), and T.

template<typename T , typename UserAllocator , typename Mutex , unsigned NextSize, unsigned MaxSize>
void boost::fast_pool_allocator< T, UserAllocator, Mutex, NextSize, MaxSize >::destroy ( const pointer  ptr)
inline

Destroy ptr using destructor.

References boost::detail::void.

template<typename T , typename UserAllocator , typename Mutex , unsigned NextSize, unsigned MaxSize>
static size_type boost::fast_pool_allocator< T, UserAllocator, Mutex, NextSize, MaxSize >::max_size ( void  )
inlinestatic
template<typename T , typename UserAllocator , typename Mutex , unsigned NextSize, unsigned MaxSize>
bool boost::fast_pool_allocator< T, UserAllocator, Mutex, NextSize, MaxSize >::operator!= ( const fast_pool_allocator< T, UserAllocator, Mutex, NextSize, MaxSize > &  ) const
inline
template<typename T , typename UserAllocator , typename Mutex , unsigned NextSize, unsigned MaxSize>
bool boost::fast_pool_allocator< T, UserAllocator, Mutex, NextSize, MaxSize >::operator== ( const fast_pool_allocator< T, UserAllocator, Mutex, NextSize, MaxSize > &  ) const
inline

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