Boost  v1.57.0
doxygen for www.boost.org
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
boost::container::node_allocator< T, NodesPerBlock, Version > Class Template Reference

An STL node allocator that uses a modified DlMalloc as memory source. More...

#include <node_allocator.hpp>

Classes

struct  rebind
 Obtains node_allocator from node_allocator. More...
 

Public Types

typedef unsigned int allocation_type
 If Version is 1, the allocator is a STL conforming allocator. More...
 
typedef node_allocator< T,
NodesPerBlock, Version > 
self_t
 
typedef T value_type
 
typedef Tpointer
 
typedef const Tconst_pointer
 
typedef
::boost::container::container_detail::unvoid
< T >::type
reference
 
typedef const
::boost::container::container_detail::unvoid
< T >::type
const_reference
 
typedef std::size_t size_type
 
typedef std::ptrdiff_t difference_type
 
typedef
boost::container::container_detail::version_type
< self_t, Version > 
version
 
typedef
boost::container::container_detail::basic_multiallocation_chain
< void * > 
multiallocation_chain_void
 
typedef
boost::container::container_detail::transform_multiallocation_chain
< multiallocation_chain_void,
T
multiallocation_chain
 

Public Member Functions

 BOOST_STATIC_ASSERT ((Version<=2))
 
 node_allocator () BOOST_CONTAINER_NOEXCEPT
 Default constructor. More...
 
 node_allocator (const node_allocator &) BOOST_CONTAINER_NOEXCEPT
 Copy constructor from other node_allocator. More...
 
template<class T2 >
 node_allocator (const node_allocator< T2, NodesPerBlock, Version > &) BOOST_CONTAINER_NOEXCEPT
 Copy constructor from related node_allocator. More...
 
 ~node_allocator () BOOST_CONTAINER_NOEXCEPT
 Destructor. More...
 
size_type max_size () const
 Returns the number of elements that could be allocated. More...
 
pointer allocate (size_type count, const void *=0)
 Allocate memory for an array of count elements. More...
 
void deallocate (const pointer &ptr, size_type count) BOOST_CONTAINER_NOEXCEPT
 Deallocate allocated memory. More...
 
std::pair< pointer, bool > allocation_command (allocation_type command, size_type limit_size, size_type preferred_size, size_type &received_size, pointer reuse=pointer())
 
size_type size (pointer p) const BOOST_CONTAINER_NOEXCEPT
 Returns maximum the number of objects the previously allocated memory pointed by p can hold. More...
 
pointer allocate_one ()
 Allocates just one object. More...
 
void allocate_individual (std::size_t num_elements, multiallocation_chain &chain)
 Allocates many elements of size == 1. More...
 
void deallocate_one (pointer p) BOOST_CONTAINER_NOEXCEPT
 Deallocates memory previously allocated with allocate_one(). More...
 
void deallocate_individual (multiallocation_chain &chain) BOOST_CONTAINER_NOEXCEPT
 
void allocate_many (size_type elem_size, std::size_t n_elements, multiallocation_chain &chain)
 Allocates many elements of size elem_size. More...
 
void allocate_many (const size_type *elem_sizes, size_type n_elements, multiallocation_chain &chain)
 Allocates n_elements elements, each one of size elem_sizes[i] Elements must be individually deallocated with deallocate() More...
 
void deallocate_many (multiallocation_chain &chain) BOOST_CONTAINER_NOEXCEPT
 

Static Public Member Functions

static void deallocate_free_blocks () BOOST_CONTAINER_NOEXCEPT
 Deallocates all free blocks of the pool. More...
 

Static Public Attributes

static const std::size_t nodes_per_block = NodesPerBlock
 

Friends

void swap (self_t &, self_t &) BOOST_CONTAINER_NOEXCEPT
 Swaps allocators. More...
 
bool operator== (const node_allocator &, const node_allocator &) BOOST_CONTAINER_NOEXCEPT
 An allocator always compares to true, as memory allocated with one instance can be deallocated by another instance. More...
 
bool operator!= (const node_allocator &, const node_allocator &) BOOST_CONTAINER_NOEXCEPT
 An allocator always compares to false, as memory allocated with one instance can be deallocated by another instance. More...
 

Detailed Description

template<class T, std::size_t NodesPerBlock, std::size_t Version>
class boost::container::node_allocator< T, NodesPerBlock, Version >

An STL node allocator that uses a modified DlMalloc as memory source.

This node allocator shares a segregated storage between all instances of node_allocator with equal sizeof(T).

NodesPerBlock is the number of nodes allocated at once when the allocator runs out of nodes

Member Typedef Documentation

template<class T , std::size_t NodesPerBlock, std::size_t Version>
typedef unsigned int boost::container::node_allocator< T, NodesPerBlock, Version >::allocation_type

If Version is 1, the allocator is a STL conforming allocator.

If Version is 2, the allocator offers advanced expand in place and burst allocation capabilities.

template<class T , std::size_t NodesPerBlock, std::size_t Version>
typedef const T* boost::container::node_allocator< T, NodesPerBlock, Version >::const_pointer
template<class T , std::size_t NodesPerBlock, std::size_t Version>
typedef const ::boost::container:: container_detail::unvoid<T>::type& boost::container::node_allocator< T, NodesPerBlock, Version >::const_reference
template<class T , std::size_t NodesPerBlock, std::size_t Version>
typedef std::ptrdiff_t boost::container::node_allocator< T, NodesPerBlock, Version >::difference_type
template<class T , std::size_t NodesPerBlock, std::size_t Version>
typedef boost::container::container_detail:: transform_multiallocation_chain<multiallocation_chain_void, T> boost::container::node_allocator< T, NodesPerBlock, Version >::multiallocation_chain
template<class T , std::size_t NodesPerBlock, std::size_t Version>
typedef boost::container::container_detail:: basic_multiallocation_chain<void*> boost::container::node_allocator< T, NodesPerBlock, Version >::multiallocation_chain_void
template<class T , std::size_t NodesPerBlock, std::size_t Version>
typedef T* boost::container::node_allocator< T, NodesPerBlock, Version >::pointer
template<class T , std::size_t NodesPerBlock, std::size_t Version>
typedef ::boost::container:: container_detail::unvoid<T>::type& boost::container::node_allocator< T, NodesPerBlock, Version >::reference
template<class T , std::size_t NodesPerBlock, std::size_t Version>
typedef node_allocator<T, NodesPerBlock, Version> boost::container::node_allocator< T, NodesPerBlock, Version >::self_t
template<class T , std::size_t NodesPerBlock, std::size_t Version>
typedef std::size_t boost::container::node_allocator< T, NodesPerBlock, Version >::size_type
template<class T , std::size_t NodesPerBlock, std::size_t Version>
typedef T boost::container::node_allocator< T, NodesPerBlock, Version >::value_type
template<class T , std::size_t NodesPerBlock, std::size_t Version>
typedef boost::container::container_detail:: version_type<self_t, Version> boost::container::node_allocator< T, NodesPerBlock, Version >::version

Constructor & Destructor Documentation

template<class T , std::size_t NodesPerBlock, std::size_t Version>
boost::container::node_allocator< T, NodesPerBlock, Version >::node_allocator ( )
inline

Default constructor.

template<class T , std::size_t NodesPerBlock, std::size_t Version>
boost::container::node_allocator< T, NodesPerBlock, Version >::node_allocator ( const node_allocator< T, NodesPerBlock, Version > &  )
inline

Copy constructor from other node_allocator.

template<class T , std::size_t NodesPerBlock, std::size_t Version>
template<class T2 >
boost::container::node_allocator< T, NodesPerBlock, Version >::node_allocator ( const node_allocator< T2, NodesPerBlock, Version > &  )
inline

Copy constructor from related node_allocator.

template<class T , std::size_t NodesPerBlock, std::size_t Version>
boost::container::node_allocator< T, NodesPerBlock, Version >::~node_allocator ( )
inline

Destructor.

Member Function Documentation

template<class T , std::size_t NodesPerBlock, std::size_t Version>
pointer boost::container::node_allocator< T, NodesPerBlock, Version >::allocate ( size_type  count,
const void *  = 0 
)
inline

Allocate memory for an array of count elements.

Throws std::bad_alloc if there is no enough memory

References boost::container::node_allocator< T, NodesPerBlock, Version >::max_size(), T, and boost::container::throw_bad_alloc().

template<class T , std::size_t NodesPerBlock, std::size_t Version>
void boost::container::node_allocator< T, NodesPerBlock, Version >::allocate_individual ( std::size_t  num_elements,
multiallocation_chain chain 
)
inline

Allocates many elements of size == 1.

Elements must be individually deallocated with deallocate_one()

References boost::container::node_allocator< T, NodesPerBlock, Version >::BOOST_STATIC_ASSERT(), and T.

template<class T , std::size_t NodesPerBlock, std::size_t Version>
void boost::container::node_allocator< T, NodesPerBlock, Version >::allocate_many ( size_type  elem_size,
std::size_t  n_elements,
multiallocation_chain chain 
)
inline

Allocates many elements of size elem_size.

Elements must be individually deallocated with deallocate()

References boost::container::node_allocator< T, NodesPerBlock, Version >::BOOST_STATIC_ASSERT(), and boost::container::throw_bad_alloc().

template<class T , std::size_t NodesPerBlock, std::size_t Version>
void boost::container::node_allocator< T, NodesPerBlock, Version >::allocate_many ( const size_type elem_sizes,
size_type  n_elements,
multiallocation_chain chain 
)
inline

Allocates n_elements elements, each one of size elem_sizes[i] Elements must be individually deallocated with deallocate()

References boost::container::node_allocator< T, NodesPerBlock, Version >::BOOST_STATIC_ASSERT(), and boost::container::throw_bad_alloc().

template<class T , std::size_t NodesPerBlock, std::size_t Version>
pointer boost::container::node_allocator< T, NodesPerBlock, Version >::allocate_one ( )
inline

Allocates just one object.

Memory allocated with this function must be deallocated only with deallocate_one(). Throws bad_alloc if there is no enough memory

References boost::container::node_allocator< T, NodesPerBlock, Version >::BOOST_STATIC_ASSERT(), and T.

template<class T , std::size_t NodesPerBlock, std::size_t Version>
std::pair<pointer, bool> boost::container::node_allocator< T, NodesPerBlock, Version >::allocation_command ( allocation_type  command,
size_type  limit_size,
size_type  preferred_size,
size_type received_size,
pointer  reuse = pointer() 
)
inline
template<class T , std::size_t NodesPerBlock, std::size_t Version>
void boost::container::node_allocator< T, NodesPerBlock, Version >::deallocate ( const pointer ptr,
size_type  count 
)
inline

Deallocate allocated memory.

Never throws

References count, boost::python::ptr(), T, and boost::detail::void.

template<class T , std::size_t NodesPerBlock, std::size_t Version>
static void boost::container::node_allocator< T, NodesPerBlock, Version >::deallocate_free_blocks ( )
inlinestatic

Deallocates all free blocks of the pool.

References T.

template<class T , std::size_t NodesPerBlock, std::size_t Version>
void boost::container::node_allocator< T, NodesPerBlock, Version >::deallocate_individual ( multiallocation_chain chain)
inline
template<class T , std::size_t NodesPerBlock, std::size_t Version>
void boost::container::node_allocator< T, NodesPerBlock, Version >::deallocate_many ( multiallocation_chain chain)
inline
template<class T , std::size_t NodesPerBlock, std::size_t Version>
void boost::container::node_allocator< T, NodesPerBlock, Version >::deallocate_one ( pointer  p)
inline

Deallocates memory previously allocated with allocate_one().

You should never use deallocate_one to deallocate memory allocated with other functions different from allocate_one(). Never throws

References boost::container::node_allocator< T, NodesPerBlock, Version >::BOOST_STATIC_ASSERT(), boost::multiprecision::backends::p, and T.

template<class T , std::size_t NodesPerBlock, std::size_t Version>
size_type boost::container::node_allocator< T, NodesPerBlock, Version >::max_size ( ) const
inline

Returns the number of elements that could be allocated.

Never throws

References T.

Referenced by boost::container::node_allocator< T, NodesPerBlock, Version >::allocate().

template<class T , std::size_t NodesPerBlock, std::size_t Version>
size_type boost::container::node_allocator< T, NodesPerBlock, Version >::size ( pointer  p) const
inline

Returns maximum the number of objects the previously allocated memory pointed by p can hold.

References boost::container::node_allocator< T, NodesPerBlock, Version >::BOOST_STATIC_ASSERT(), and boost::multiprecision::backends::p.

Friends And Related Function Documentation

template<class T , std::size_t NodesPerBlock, std::size_t Version>
bool operator!= ( const node_allocator< T, NodesPerBlock, Version > &  ,
const node_allocator< T, NodesPerBlock, Version > &   
)
friend

An allocator always compares to false, as memory allocated with one instance can be deallocated by another instance.

template<class T , std::size_t NodesPerBlock, std::size_t Version>
bool operator== ( const node_allocator< T, NodesPerBlock, Version > &  ,
const node_allocator< T, NodesPerBlock, Version > &   
)
friend

An allocator always compares to true, as memory allocated with one instance can be deallocated by another instance.

template<class T , std::size_t NodesPerBlock, std::size_t Version>
void swap ( self_t ,
self_t  
)
friend

Swaps allocators.

Does not throw. If each allocator is placed in a different memory segment, the result is undefined.

Member Data Documentation

template<class T , std::size_t NodesPerBlock, std::size_t Version>
const std::size_t boost::container::node_allocator< T, NodesPerBlock, Version >::nodes_per_block = NodesPerBlock
static

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