File: pool_alloc.html

package info (click to toggle)
boost 1.27.0-3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 19,908 kB
  • ctags: 26,546
  • sloc: cpp: 122,225; ansic: 10,956; python: 4,412; sh: 855; yacc: 803; makefile: 257; perl: 165; lex: 90; csh: 6
file content (127 lines) | stat: -rw-r--r-- 4,260 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<!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">&lt;new&gt;</SPAN> and <SPAN CLASS="code">&lt;limits&gt;</SPAN>.

<P>
Includes the Boost headers <SPAN CLASS="code">&quot;singleton_pool.hpp&quot;</SPAN> (see <A HREF="singleton_pool.html">singleton_pool.html</A>) and <SPAN CLASS="code">&quot;detail/mutex.hpp&quot;</SPAN> (see <A HREF="mutex.html">mutex.html</A>).

<P>
<H2>Synopsis</H2>

<PRE CLASS="code">template &lt;typename T,
    typename UserAllocator = default_user_allocator_new_delete,
    typename Mutex = details::pool::default_mutex,
    unsigned NextSize = 32&gt;
class pool_allocator
{
  public:
    ... // public interface

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

    template &lt;typename U&gt;
    struct rebind
    {
      typedef pool_allocator&lt;U, UserAllocator, Mutex, NextSize&gt; other;
    };
};

template &lt;typename T,
    typename UserAllocator = default_user_allocator_new_delete,
    typename Mutex = details::pool::default_mutex,
    unsigned NextSize = 32&gt;
class fast_pool_allocator
{
  public:
    ... // public interface

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

    template &lt;typename U&gt;
    struct rebind
    {
      typedef fast_pool_allocator&lt;U, UserAllocator, Mutex, NextSize&gt; 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 &copy; 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 &quot;as is&quot; without express or implied warranty, and with no claim as to its suitability for any purpose.

</BODY>
</HTML>