Boost C++ Libraries 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

Singleton Pool Implementation


Includes the Boost headers "pool.hpp" (see pool.html), "detail/singleton.hpp" (see singleton.html), "detail/mutex.hpp" (see mutex.html), and "detail/guard.hpp" (see guard.html).


template <typename Tag,
    unsigned RequestedSize,
    typename UserAllocator = default_user_allocator_new_delete,
    typename Mutex = details::pool::default_mutex,
    unsigned NextSize = 32>
class singleton_pool
  ... // public interface

  public: // extensions to public interface
    typedef Mutex mutex;
    static const unsigned next_size = NextSize;

Extensions to Public Interface

Additional template parameters


This class is the type of mutex to use to protect simultaneous access to the underlying Pool. It is exposed so that users may declare some singleton pools normally (i.e., with synchronization), but some singleton pools without synchronization (by specifying details::pool::null_mutex) for efficiency reasons.


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.

Additional members

The typedef mutex and the static const value next_size publish the values of the template parameters Mutex and NextSize, respectively.

Future Directions

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.

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.