Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Class template adaptive_pool

boost::container::adaptive_pool

Synopsis

// In header: <boost/container/adaptive_pool.hpp>

template<typename T,  NodesPerBlock = ADP_nodes_per_block, 
          MaxFreeBlocks = ADP_max_free_blocks, 
          OverheadPercent = ADP_overhead_percent BOOST_MOVE_I unsigned Version  )> 
class adaptive_pool {
public:
  // types
  typedef unsigned int                                                                                                   ;
  typedef adaptive_pool< T, NodesPerBlock, MaxFreeBlocks, OverheadPercent BOOST_MOVE_I Version) > ;         
  typedef T                                                                                                              ;     
  typedef T *                                                                                                            ;        
  typedef const T *                                                                                                      ;  
  typedef ::T >::                                                                 ;      
  typedef ::constT >::                                                            ;
  typedef                                                                                                     ;      
  typedef                                                                                                  ;
  typedef self_t, Version >                                                         ;        

  // member classes/structs/unions
  template<typename T2> 
  struct rebind {
    // types
    typedef adaptive_pool< T2, NodesPerBlock, MaxFreeBlocks, OverheadPercent BOOST_MOVE_I Version) > ;
  };

  // construct/copy/destruct
  () ;
  (const adaptive_pool &) ;
  template<typename T2> 
    (const adaptive_pool< T2, NodesPerBlock, MaxFreeBlocks, OverheadPercent BOOST_MOVE_I Version)> &) ;
  adaptive_pool & (const adaptive_pool &) ;
  ~();

  // public member functions
   (Version<=);
   () ;
   (, const void * = );
  void (const , ) ;
   (, , , 
                             );
   () ;
   ();
  void (, );
  void () ;
  void () ;
  void (, , );
  void (const , , );
  void () ;

  // public static functions
  void () ;

  // friend functions
  void (adaptive_pool &, adaptive_pool &) ;
  bool (const adaptive_pool &, const adaptive_pool &) ;
  bool (const adaptive_pool &, const adaptive_pool &) ;

  // private member functions
   (, , , 
                                  );

  // public data members
  static const  nodes_per_block;
  static const  max_free_blocks;
  static const  overhead_percent;
  static const  real_nodes_per_block;
};

Description

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

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

NodesPerBlock is the number of nodes allocated at once when the allocator needs runs out of nodes. MaxFreeBlocks is the maximum number of totally free blocks that the adaptive node pool will hold. The rest of the totally free blocks will be deallocated to the memory manager.

OverheadPercent is the (approximated) maximum size overhead (1-20%) of the allocator: (memory usable for nodes / total memory allocated from the memory allocator)

adaptive_pool public types

  1. typedef unsigned int ;

    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.

adaptive_pool public construct/copy/destruct

  1. () ;
    Default constructor.
  2. (const adaptive_pool &) ;
    Copy constructor from other adaptive_pool.
  3. template<typename T2> 
      (const adaptive_pool< T2, NodesPerBlock, MaxFreeBlocks, OverheadPercent BOOST_MOVE_I Version)> &) ;
    Copy constructor from related adaptive_pool.
  4. adaptive_pool & (const adaptive_pool &) ;
    Copy assignment from other adaptive_pool.
  5. ~();
    Destructor.

adaptive_pool public member functions

  1.  (Version<=);
  2.  () ;

    Returns the number of elements that could be allocated. Never throws

  3.  ( count, const void * = );

    Allocate memory for an array of count elements. Throws bad_alloc if there is no enough memory

  4. void (const  ptr,  count) ;

    Deallocate allocated memory. Never throws

  5.  ( command,  limit_size, 
                                prefer_in_recvd_out_size, 
                                reuse);
  6.  ( p) ;

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

  7.  ();

    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

  8. void ( num_elements, 
                              chain);

    Allocates many elements of size == 1. Elements must be individually deallocated with deallocate_one()

  9. void ( p) ;

    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

  10. void ( chain) ;
  11. void ( elem_size,  n_elements, 
                        chain);

    Allocates many elements of size elem_size. Elements must be individually deallocated with deallocate()

  12. void (const  elem_sizes,  n_elements, 
                        chain);

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

  13. void ( chain) ;

adaptive_pool public static functions

  1. void () ;
    Deallocates all free blocks of the pool.

adaptive_pool friend functions

  1. void (adaptive_pool &, adaptive_pool &) ;

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

  2. bool (const adaptive_pool &, const adaptive_pool &) ;

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

  3. bool (const adaptive_pool &, const adaptive_pool &) ;

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

adaptive_pool private member functions

  1.  ( command, 
                                     limit_size, 
                                     prefer_in_recvd_out_size, 
                                     reuse_ptr);

PrevUpHomeNext