Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of boost. Click here for the latest Boost documentation.
C++ Boost

Object Pool Implementation

Dependencies

Includes the Boost header "pool.hpp" (see pool.html).

Extensions to Public Interface

Whenever an object of type ObjectPool needs memory from the system, it will request it from its UserAllocator template parameter. The amount requested is determined using a doubling algorithm; that is, each time more system memory is allocated, the amount of system memory requested is doubled. Users may control the doubling algorithm by using the following extensions.

Additional constructor parameter

Users may pass an additional constructor parameter to ObjectPool. This parameter is of type size_type, and is the number of chunks to request from the system the first time that object needs to allocate system memory. The default is 32. This parameter may not be 0.

next_size accessor functions

The pair of functions size_type get_next_size() const; and void set_next_size(size_type); allow users to explicitly read and write the next_size value. This value is the number of chunks to request from the system the next time that object needs to allocate system memory. This value should never be set to 0.

Protected Interface

Synopsis

template <typename ElementType, typename UserAllocator = default_user_allocator_new_delete>
class object_pool: protected pool<UserAllocator>
{
  ... // public interface
};

Protected Derivation

ObjectPool derives from a simple segregated storage via protected derivation; this exposes all the Pool implementation details to all classes derived from ObjectPool as well.

Interface Description


Valid HTML 4.01 Transitional

Revised 05 December, 2006

Copyright © 2000, 2001 Stephen Cleary (scleary AT jerviswebb DOT com)

Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)