1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
---|
2 | <HTML> |
---|
3 | <HEAD> |
---|
4 | <TITLE>pool_alloc - Boost Pool Standard Allocators Implementation</TITLE> |
---|
5 | <LINK HREF="../pool.css" REL="stylesheet" TYPE="text/css"> |
---|
6 | </HEAD> |
---|
7 | <BODY> |
---|
8 | |
---|
9 | <IMG SRC="../../../../boost.png" WIDTH=276 HEIGHT=86 ALT="C++ Boost"> |
---|
10 | |
---|
11 | <H1 ALIGN=CENTER>pool_alloc - Boost Pool Standard Allocators Implementation</H1> |
---|
12 | |
---|
13 | <P> |
---|
14 | <H2>Dependencies</H2> |
---|
15 | |
---|
16 | <P> |
---|
17 | Includes the system headers <SPAN CLASS="code"><new></SPAN> and <SPAN CLASS="code"><limits></SPAN>. |
---|
18 | |
---|
19 | <P> |
---|
20 | 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>). |
---|
21 | |
---|
22 | <P> |
---|
23 | <H2>Synopsis</H2> |
---|
24 | |
---|
25 | <PRE CLASS="code">template <typename T, |
---|
26 | typename UserAllocator = default_user_allocator_new_delete, |
---|
27 | typename Mutex = details::pool::default_mutex, |
---|
28 | unsigned NextSize = 32> |
---|
29 | class pool_allocator |
---|
30 | { |
---|
31 | public: |
---|
32 | ... // public interface |
---|
33 | |
---|
34 | public: // extensions to public interface |
---|
35 | typedef Mutex mutex; |
---|
36 | static const unsigned next_size = NextSize; |
---|
37 | |
---|
38 | template <typename U> |
---|
39 | struct rebind |
---|
40 | { |
---|
41 | typedef pool_allocator<U, UserAllocator, Mutex, NextSize> other; |
---|
42 | }; |
---|
43 | }; |
---|
44 | |
---|
45 | template <typename T, |
---|
46 | typename UserAllocator = default_user_allocator_new_delete, |
---|
47 | typename Mutex = details::pool::default_mutex, |
---|
48 | unsigned NextSize = 32> |
---|
49 | class fast_pool_allocator |
---|
50 | { |
---|
51 | public: |
---|
52 | ... // public interface |
---|
53 | |
---|
54 | public: // extensions to public interface |
---|
55 | typedef Mutex mutex; |
---|
56 | static const unsigned next_size = NextSize; |
---|
57 | |
---|
58 | template <typename U> |
---|
59 | struct rebind |
---|
60 | { |
---|
61 | typedef fast_pool_allocator<U, UserAllocator, Mutex, NextSize> other; |
---|
62 | }; |
---|
63 | };</PRE> |
---|
64 | |
---|
65 | <P> |
---|
66 | <H2>Extensions to Public Interface</H2> |
---|
67 | |
---|
68 | <P> |
---|
69 | <H3>Additional template parameters</H3> |
---|
70 | |
---|
71 | <P> |
---|
72 | <H4 CLASS="code">Mutex</H4> |
---|
73 | |
---|
74 | <P> |
---|
75 | 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. |
---|
76 | |
---|
77 | <P> |
---|
78 | <H4 CLASS="code">NextSize</H4> |
---|
79 | |
---|
80 | <P> |
---|
81 | 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. |
---|
82 | |
---|
83 | <P> |
---|
84 | <H3>Modification of <SPAN CLASS="code">rebind</SPAN></H3> |
---|
85 | |
---|
86 | <P> |
---|
87 | The struct <SPAN CLASS="code">rebind</SPAN> has been redefined to preserve the values of the additional template parameters. |
---|
88 | |
---|
89 | <P> |
---|
90 | <H3>Additional members</H3> |
---|
91 | |
---|
92 | <P> |
---|
93 | 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. |
---|
94 | |
---|
95 | <P> |
---|
96 | <H2>Notes</H2> |
---|
97 | |
---|
98 | <P> |
---|
99 | 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: |
---|
100 | <UL> |
---|
101 | <LI>Borland C++ (Builder and command-line compiler) with default (RogueWave) library, ver. 5 and earlier</LI> |
---|
102 | <LI>STLport (with any compiler), ver. 4.0 and earlier</LI> |
---|
103 | </UL> |
---|
104 | |
---|
105 | <P> |
---|
106 | <H2>Future Directions</H2> |
---|
107 | |
---|
108 | <P> |
---|
109 | 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. |
---|
110 | |
---|
111 | <P> |
---|
112 | <H2><A HREF="../interfaces/pool_alloc.html">Interface Description</A></H2> |
---|
113 | |
---|
114 | <P> |
---|
115 | <HR> |
---|
116 | |
---|
117 | <P> |
---|
118 | Copyright © 2000, 2001 Stephen Cleary (scleary AT jerviswebb DOT com) |
---|
119 | |
---|
120 | <P> |
---|
121 | This file can be redistributed and/or modified under the terms found in <A HREF="../copyright.html">copyright.html</A> |
---|
122 | |
---|
123 | <P> |
---|
124 | 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. |
---|
125 | |
---|
126 | </BODY> |
---|
127 | </HTML> |
---|