1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" |
---|
2 | "http://www.w3.org/TR/html4/loose.dtd"> |
---|
3 | |
---|
4 | <html> |
---|
5 | <head> |
---|
6 | <meta http-equiv="Content-Language" content="en-us"> |
---|
7 | <meta http-equiv="Content-Type" content="text/html; charset=us-ascii"> |
---|
8 | <link href="../pool.css" rel="stylesheet" type="text/css"> |
---|
9 | |
---|
10 | <title>Object Pool Implementation</title> |
---|
11 | </head> |
---|
12 | |
---|
13 | <body> |
---|
14 | <img src="../../../../boost.png" width="276" height="86" alt="C++ Boost"> |
---|
15 | |
---|
16 | <h1 align="center">Object Pool Implementation</h1> |
---|
17 | |
---|
18 | <h2>Dependencies</h2> |
---|
19 | |
---|
20 | <p>Includes the Boost header <span class="code">"pool.hpp"</span> (see |
---|
21 | <a href="pool.html">pool.html</a>).</p> |
---|
22 | |
---|
23 | <h2>Extensions to Public Interface</h2> |
---|
24 | |
---|
25 | <p>Whenever an object of type <span class="code">ObjectPool</span> needs |
---|
26 | memory from the system, it will request it from its <span class= |
---|
27 | "code">UserAllocator</span> template parameter. The amount requested is |
---|
28 | determined using a doubling algorithm; that is, each time more system |
---|
29 | memory is allocated, the amount of system memory requested is doubled. |
---|
30 | Users may control the doubling algorithm by using the following |
---|
31 | extensions.</p> |
---|
32 | |
---|
33 | <h3>Additional constructor parameter</h3> |
---|
34 | |
---|
35 | <p>Users may pass an additional constructor parameter to <span class= |
---|
36 | "code">ObjectPool</span>. This parameter is of type <span class= |
---|
37 | "code">size_type</span>, and is the number of chunks to request from the |
---|
38 | system the first time that object needs to allocate system memory. The |
---|
39 | default is 32. This parameter may not be 0.</p> |
---|
40 | |
---|
41 | <h3><span class="code">next_size</span> accessor functions</h3> |
---|
42 | |
---|
43 | <p>The pair of functions <span class="code">size_type get_next_size() |
---|
44 | const;</span> and <span class="code">void set_next_size(size_type);</span> |
---|
45 | allow users to explicitly read and write the <span class= |
---|
46 | "code">next_size</span> value. This value is the number of chunks to |
---|
47 | request from the system the next time that object needs to allocate system |
---|
48 | memory. This value should never be set to 0.</p> |
---|
49 | |
---|
50 | <h2>Protected Interface</h2> |
---|
51 | |
---|
52 | <h3>Synopsis</h3> |
---|
53 | <pre class="code"> |
---|
54 | template <typename ElementType, typename UserAllocator = default_user_allocator_new_delete> |
---|
55 | class object_pool: protected pool<UserAllocator> |
---|
56 | { |
---|
57 | ... // public interface |
---|
58 | }; |
---|
59 | </pre> |
---|
60 | |
---|
61 | <h3>Protected Derivation</h3>ObjectPool derives from a simple segregated |
---|
62 | storage via protected derivation; this exposes all the <a href= |
---|
63 | "pool.html">Pool implementation details</a> to all classes derived from |
---|
64 | ObjectPool as well. |
---|
65 | |
---|
66 | <h2><a href="../interfaces/object_pool.html">Interface Description</a></h2> |
---|
67 | <hr> |
---|
68 | |
---|
69 | <p><a href="http://validator.w3.org/check?uri=referer"><img border="0" src= |
---|
70 | "http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" |
---|
71 | height="31" width="88"></a></p> |
---|
72 | |
---|
73 | <p>Revised |
---|
74 | <!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %B, %Y" startspan -->05 |
---|
75 | December, 2006<!--webbot bot="Timestamp" endspan i-checksum="38516" --></p> |
---|
76 | |
---|
77 | <p><i>Copyright © 2000, 2001 Stephen Cleary (scleary AT jerviswebb DOT |
---|
78 | com)</i></p> |
---|
79 | |
---|
80 | <p><i>Distributed under the Boost Software License, Version 1.0. (See |
---|
81 | accompanying file <a href="../../../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> |
---|
82 | or copy at <a href= |
---|
83 | "http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</a>)</i></p> |
---|
84 | </body> |
---|
85 | </html> |
---|