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


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

This file can be redistributed and/or modified under the terms found in copyright.html

This software and its documentation is provided "as is" without express or implied warranty, and with no claim as to its suitability for any purpose.