...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
Includes the system headers <new> and <limits>.
Includes the Boost headers "singleton_pool.hpp" (see singleton_pool.html) and "detail/mutex.hpp" (see mutex.html).
template <typename T, typename UserAllocator = default_user_allocator_new_delete, typename Mutex = details::pool::default_mutex, unsigned NextSize = 32> class pool_allocator { public: ... // public interface public: // extensions to public interface typedef Mutex mutex; static const unsigned next_size = NextSize; template <typename U> struct rebind { typedef pool_allocator<U, UserAllocator, Mutex, NextSize> other; }; }; template <typename T, typename UserAllocator = default_user_allocator_new_delete, typename Mutex = details::pool::default_mutex, unsigned NextSize = 32> class fast_pool_allocator { public: ... // public interface public: // extensions to public interface typedef Mutex mutex; static const unsigned next_size = NextSize; template <typename U> struct rebind { typedef fast_pool_allocator<U, UserAllocator, Mutex, NextSize> other; }; };
This parameter allows the user to determine the type of synchronization to be used on the underlying singleton pool. See the extensions to the public interface of singleton pool for more information.
The value of this parameter is passed to the underlying Pool when it is created. See the extensions to the public interface of pool for more information.
The struct rebind has been redefined to preserve the values of the additional template parameters.
The typedef mutex and the static const value next_size publish the values of the template parameters Mutex and NextSize, respectively.
A number of common STL libraries contain bugs in their using of allocators. Specifically, they pass null pointers to the deallocate function, which is explicitly forbidden by the Standard [20.1.5 Table 32]. PoolAlloc will work around these libraries if it detects them; currently, workarounds are in place for:
When the Boost multithreading library is completed, the Mutex parameter will be replaced by something from that library providing the same flexibility and will move from an implementation detail into the interface specification.
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)