![]() |
Home | Libraries | People | FAQ | More |
boost::container::adaptive_pool
// In header: <boost/container/adaptive_pool.hpp> template<typename T, NodesPerBlock = , MaxFreeBlocks = , OverheadPercent = > class adaptive_pool { public: // types typedef ; typedef adaptive_pool< ; typedef ; typedef ; typedef ; typedef :: ; typedef :: ; typedef ; typedef ; typedef self_t, ; // member classes/structs/unions template<typename T2> struct rebind { // types typedef adaptive_pool< ; }; // construct/copy/destruct () ; (adaptive_pool &) ; template<typename T2> (adaptive_pool< ) ; ~(); // public member functions (); () ; (, = ); (, ) ; (, , , ); () ; (); (, ); () ; () ; (, , ); (, , ); () ; // public static functions () ; // friend functions (adaptive_pool &, adaptive_pool &) ; (adaptive_pool &, adaptive_pool &) ; (adaptive_pool &, adaptive_pool &) ; // private member functions (, , , ); // public data members static nodes_per_block; static max_free_blocks; static overhead_percent; static real_nodes_per_block; };
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
construct/copy/destruct() ;Default constructor.
(adaptive_pool &) ;Copy constructor from other
adaptive_pool
. template<typename T2> (adaptive_pool< ) ;Copy constructor from related
adaptive_pool
. ~();Destructor.
adaptive_pool
public member functions();
() ;
Returns the number of elements that could be allocated. Never throws
( count, = );
Allocate memory for an array of count elements. Throws std::bad_alloc if there is no enough memory
( ptr, count) ;
Deallocate allocated memory. Never throws
( command, limit_size, prefer_in_recvd_out_size, reuse);
( p) ;
Returns maximum the number of objects the previously allocated memory pointed by p can hold.
();
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
( num_elements, chain);
Allocates many elements of size == 1. Elements must be individually deallocated with deallocate_one()
( 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
( chain) ;
( elem_size, n_elements, chain);
Allocates many elements of size elem_size. Elements must be individually deallocated with deallocate()
( elem_sizes, n_elements, chain);
Allocates n_elements elements, each one of size elem_sizes[i] Elements must be individually deallocated with deallocate()
( chain) ;
adaptive_pool
friend functions(adaptive_pool &, adaptive_pool &) ;
Swaps allocators. Does not throw. If each allocator is placed in a different memory segment, the result is undefined.
(adaptive_pool &, adaptive_pool &) ;
An allocator always compares to true, as memory allocated with one instance can be deallocated by another instance
(adaptive_pool &, adaptive_pool &) ;
An allocator always compares to false, as memory allocated with one instance can be deallocated by another instance