mirror of
https://github.com/boostorg/pool.git
synced 2026-01-24 18:12:34 +00:00
127 lines
4.2 KiB
HTML
127 lines
4.2 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
<HTML>
|
|
<HEAD>
|
|
<TITLE>pool_alloc - Boost Pool Standard Allocators Implementation</TITLE>
|
|
<LINK HREF="../pool.css" REL="stylesheet" TYPE="text/css">
|
|
</HEAD>
|
|
<BODY>
|
|
|
|
<IMG SRC="../../../../c++boost.gif" WIDTH=276 HEIGHT=86 ALT="C++ Boost">
|
|
|
|
<H1 ALIGN=CENTER>pool_alloc - Boost Pool Standard Allocators Implementation</H1>
|
|
|
|
<P>
|
|
<H2>Dependencies</H2>
|
|
|
|
<P>
|
|
Includes the system headers <SPAN CLASS="code"><new></SPAN> and <SPAN CLASS="code"><limits></SPAN>.
|
|
|
|
<P>
|
|
Includes the Boost headers <SPAN CLASS="code">"singleton_pool.hpp"</SPAN> (see <A HREF="singleton_pool.html">singleton_pool.html</A>) and <SPAN CLASS="code">"detail/mutex.hpp"</SPAN> (see <A HREF="mutex.html">mutex.html</A>).
|
|
|
|
<P>
|
|
<H2>Synopsis</H2>
|
|
|
|
<PRE CLASS="code">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;
|
|
};
|
|
};</PRE>
|
|
|
|
<P>
|
|
<H2>Extensions to Public Interface</H2>
|
|
|
|
<P>
|
|
<H3>Additional template parameters</H3>
|
|
|
|
<P>
|
|
<H4 CLASS="code">Mutex</H4>
|
|
|
|
<P>
|
|
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 <A HREF="singleton_pool.html">singleton pool</A> for more information.
|
|
|
|
<P>
|
|
<H4 CLASS="code">NextSize</H4>
|
|
|
|
<P>
|
|
The value of this parameter is passed to the underlying Pool when it is created. See the extensions to the public interface of <A HREF="pool.html">pool</A> for more information.
|
|
|
|
<P>
|
|
<H3>Modification of <SPAN CLASS="code">rebind</SPAN></H3>
|
|
|
|
<P>
|
|
The struct <SPAN CLASS="code">rebind</SPAN> has been redefined to preserve the values of the additional template parameters.
|
|
|
|
<P>
|
|
<H3>Additional members</H3>
|
|
|
|
<P>
|
|
The typedef <SPAN CLASS="code">mutex</SPAN> and the static const value <SPAN CLASS="code">next_size</SPAN> publish the values of the template parameters <SPAN CLASS="code">Mutex</SPAN> and <SPAN CLASS="code">NextSize</SPAN>, respectively.
|
|
|
|
<P>
|
|
<H2>Notes</H2>
|
|
|
|
<P>
|
|
A number of common STL libraries contain bugs in their using of allocators. Specifically, they pass null pointers to the <SPAN CLASS="code">deallocate</SPAN> 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:
|
|
<UL>
|
|
<LI>Borland C++ (Builder and command-line compiler) with default (RogueWave) library, ver. 5 and earlier</LI>
|
|
<LI>STLport (with any compiler), ver. 4.0 and earlier</LI>
|
|
</UL>
|
|
|
|
<P>
|
|
<H2>Future Directions</H2>
|
|
|
|
<P>
|
|
When the Boost multithreading library is completed, the <SPAN CLASS="code">Mutex</SPAN> parameter will be replaced by something from that library providing the same flexibility and will move from an implementation detail into the interface specification.
|
|
|
|
<P>
|
|
<H2><A HREF="../interfaces/pool_alloc.html">Interface Description</A></H2>
|
|
|
|
<P>
|
|
<HR>
|
|
|
|
<P>
|
|
Copyright © 2000, 2001 Stephen Cleary (<A HREF="mailto:shammah@voyager.net">shammah@voyager.net</A>)
|
|
|
|
<P>
|
|
This file can be redistributed and/or modified under the terms found in <A HREF="../copyright.html">copyright.html</A>
|
|
|
|
<P>
|
|
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.
|
|
|
|
</BODY>
|
|
</HTML> |