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>Object Pool 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>Object Pool Implementation</H1> |
---|
12 | |
---|
13 | <P> |
---|
14 | <H2>Dependencies</H2> |
---|
15 | |
---|
16 | <P> |
---|
17 | Includes the Boost header <SPAN CLASS="code">"pool.hpp"</SPAN> (see <A HREF="pool.html">pool.html</A>). |
---|
18 | |
---|
19 | <P> |
---|
20 | <H2>Extensions to Public Interface</H2> |
---|
21 | |
---|
22 | <P> |
---|
23 | Whenever an object of type <SPAN CLASS="code">ObjectPool</SPAN> needs memory from the system, it will request it from its <SPAN CLASS="code">UserAllocator</SPAN> template parameter. The amount requested is determined using a doubling algorithm; that is, each time more system memory is allocated, the amount of system memory requested is doubled. Users may control the doubling algorithm by using the following extensions. |
---|
24 | |
---|
25 | <P> |
---|
26 | <H3>Additional constructor parameter</H3> |
---|
27 | |
---|
28 | <P> |
---|
29 | Users may pass an additional constructor parameter to <SPAN CLASS="code">ObjectPool</SPAN>. This parameter is of type <SPAN CLASS="code">size_type</SPAN>, and is the number of chunks to request from the system the first time that object needs to allocate system memory. The default is 32. This parameter may not be 0. |
---|
30 | |
---|
31 | <P> |
---|
32 | <H3><SPAN CLASS="code">next_size</SPAN> accessor functions</H3> |
---|
33 | |
---|
34 | <P> |
---|
35 | The pair of functions <SPAN CLASS="code">size_type get_next_size() const;</SPAN> and <SPAN CLASS="code">void set_next_size(size_type);</SPAN> allow users to explicitly read and write the <SPAN CLASS="code">next_size</SPAN> value. This value is the number of chunks to request from the system the next time that object needs to allocate system memory. This value should never be set to 0. |
---|
36 | |
---|
37 | <P> |
---|
38 | <H2>Protected Interface</H2> |
---|
39 | |
---|
40 | <P> |
---|
41 | <H3>Synopsis</H3> |
---|
42 | |
---|
43 | <PRE CLASS="code">template <typename ElementType, typename UserAllocator = default_user_allocator_new_delete> |
---|
44 | class object_pool: protected pool<UserAllocator> |
---|
45 | { |
---|
46 | ... // public interface |
---|
47 | };</PRE> |
---|
48 | |
---|
49 | <P> |
---|
50 | <H3>Protected Derivation</H3> |
---|
51 | |
---|
52 | ObjectPool derives from a simple segregated storage via protected derivation; this exposes all the <A HREF="pool.html">Pool implementation details</A> to all classes derived from ObjectPool as well. |
---|
53 | |
---|
54 | <P> |
---|
55 | <H2><A HREF="../interfaces/object_pool.html">Interface Description</A></H2> |
---|
56 | |
---|
57 | <P> |
---|
58 | <HR> |
---|
59 | |
---|
60 | <P> |
---|
61 | Copyright © 2000, 2001 Stephen Cleary (scleary AT jerviswebb DOT com) |
---|
62 | |
---|
63 | <P> |
---|
64 | This file can be redistributed and/or modified under the terms found in <A HREF="../copyright.html">copyright.html</A> |
---|
65 | |
---|
66 | <P> |
---|
67 | 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. |
---|
68 | |
---|
69 | </BODY> |
---|
70 | </HTML> |
---|