3 <meta http-equiv=
"Content-Type" content=
"text/html; charset=US-ASCII">
4 <title>Class pooled_fixedsize_stack
</title>
5 <link rel=
"stylesheet" href=
"../../../../../../doc/src/boostbook.css" type=
"text/css">
6 <meta name=
"generator" content=
"DocBook XSL Stylesheets V1.75.2">
7 <link rel=
"home" href=
"../../index.html" title=
"Chapter 1. Context">
8 <link rel=
"up" href=
"../stack.html" title=
"Stack allocation">
9 <link rel=
"prev" href=
"protected_fixedsize.html" title=
"Class protected_fixedsize">
10 <link rel=
"next" href=
"fixedsize.html" title=
"Class fixedsize_stack">
12 <body bgcolor=
"white" text=
"black" link=
"#0000FF" vlink=
"#840084" alink=
"#0000FF">
13 <table cellpadding=
"2" width=
"100%"><tr>
14 <td valign=
"top"><img alt=
"Boost C++ Libraries" width=
"277" height=
"86" src=
"../../../../../../boost.png"></td>
15 <td align=
"center"><a href=
"../../../../../../index.html">Home
</a></td>
16 <td align=
"center"><a href=
"../../../../../../libs/libraries.htm">Libraries
</a></td>
17 <td align=
"center"><a href=
"http://www.boost.org/users/people.html">People
</a></td>
18 <td align=
"center"><a href=
"http://www.boost.org/users/faq.html">FAQ
</a></td>
19 <td align=
"center"><a href=
"../../../../../../more/index.htm">More
</a></td>
22 <div class=
"spirit-nav">
23 <a accesskey=
"p" href=
"protected_fixedsize.html"><img src=
"../../../../../../doc/src/images/prev.png" alt=
"Prev"></a><a accesskey=
"u" href=
"../stack.html"><img src=
"../../../../../../doc/src/images/up.png" alt=
"Up"></a><a accesskey=
"h" href=
"../../index.html"><img src=
"../../../../../../doc/src/images/home.png" alt=
"Home"></a><a accesskey=
"n" href=
"fixedsize.html"><img src=
"../../../../../../doc/src/images/next.png" alt=
"Next"></a>
26 <div class=
"titlepage"><div><div><h3 class=
"title">
27 <a name=
"context.stack.pooled_fixedsize"></a><a class=
"link" href=
"pooled_fixedsize.html" title=
"Class pooled_fixedsize_stack">Class
<span class=
"emphasis"><em>pooled_fixedsize_stack
</em></span></a>
28 </h3></div></div></div>
30 <span class=
"bold"><strong>Boost.Context
</strong></span> provides the class
<span class=
"emphasis"><em>pooled_fixedsize_stack
</em></span>
31 which models the
<span class=
"emphasis"><em>stack-allocator concept
</em></span>. In contrast
32 to
<span class=
"emphasis"><em>protected_fixedsize_stack
</em></span> it does not append a guard
33 page at the end of each stack. The memory is managed internally by
<a href=
"http://www.boost.org/doc/libs/release/libs/pool/doc/html/boost/pool.html" target=
"_top"><code class=
"computeroutput"><span class=
"identifier">boost
</span><span class=
"special">::
</span><span class=
"identifier">pool
</span><span class=
"special"><></span></code></a>.
35 <pre class=
"programlisting"><span class=
"preprocessor">#include
</span> <span class=
"special"><</span><span class=
"identifier">boost
</span><span class=
"special">/
</span><span class=
"identifier">context
</span><span class=
"special">/
</span><span class=
"identifier">pooled_fixedsize_stack
</span><span class=
"special">.
</span><span class=
"identifier">hpp
</span><span class=
"special">></span>
37 <span class=
"keyword">template
</span><span class=
"special"><</span> <span class=
"keyword">typename
</span> <span class=
"identifier">traitsT
</span> <span class=
"special">></span>
38 <span class=
"keyword">struct
</span> <span class=
"identifier">basic_pooled_fixedsize_stack
</span> <span class=
"special">{
</span>
39 <span class=
"keyword">typedef
</span> <span class=
"identifier">traitT
</span> <span class=
"identifier">traits_type
</span><span class=
"special">;
</span>
41 <span class=
"identifier">basic_pooled_fixedsize_stack
</span><span class=
"special">(
</span><span class=
"identifier">std
</span><span class=
"special">::
</span><span class=
"identifier">size_t
</span> <span class=
"identifier">stack_size
</span> <span class=
"special">=
</span> <span class=
"identifier">traits_type
</span><span class=
"special">::
</span><span class=
"identifier">default_size
</span><span class=
"special">(),
</span> <span class=
"identifier">std
</span><span class=
"special">::
</span><span class=
"identifier">size_t
</span> <span class=
"identifier">next_size
</span> <span class=
"special">=
</span> <span class=
"number">32</span><span class=
"special">,
</span> <span class=
"identifier">std
</span><span class=
"special">::
</span><span class=
"identifier">size_t
</span> <span class=
"identifier">max_size
</span> <span class=
"special">=
</span> <span class=
"number">0</span><span class=
"special">);
</span>
43 <span class=
"identifier">stack_context
</span> <span class=
"identifier">allocate
</span><span class=
"special">();
</span>
45 <span class=
"keyword">void
</span> <span class=
"identifier">deallocate
</span><span class=
"special">(
</span> <span class=
"identifier">stack_context
</span> <span class=
"special">&);
</span>
46 <span class=
"special">}
</span>
48 <span class=
"keyword">typedef
</span> <span class=
"identifier">basic_pooled_fixedsize_stack
</span><span class=
"special"><</span> <span class=
"identifier">stack_traits
</span> <span class=
"special">></span> <span class=
"identifier">pooled_fixedsize_stack
</span><span class=
"special">;
</span>
51 <a name=
"context.stack.pooled_fixedsize.h0"></a>
52 <span><a name=
"context.stack.pooled_fixedsize._code__phrase_role__identifier__basic_pooled_fixedsize_stack__phrase__phrase_role__special_____phrase__phrase_role__identifier__std__phrase__phrase_role__special______phrase__phrase_role__identifier__size_t__phrase___phrase_role__identifier__stack_size__phrase__phrase_role__special_____phrase___phrase_role__identifier__std__phrase__phrase_role__special______phrase__phrase_role__identifier__size_t__phrase___phrase_role__identifier__next_size__phrase__phrase_role__special_____phrase___phrase_role__identifier__std__phrase__phrase_role__special______phrase__phrase_role__identifier__size_t__phrase___phrase_role__identifier__max_size__phrase__phrase_role__special_____phrase___code_"></a></span><a class=
"link" href=
"pooled_fixedsize.html#context.stack.pooled_fixedsize._code__phrase_role__identifier__basic_pooled_fixedsize_stack__phrase__phrase_role__special_____phrase__phrase_role__identifier__std__phrase__phrase_role__special______phrase__phrase_role__identifier__size_t__phrase___phrase_role__identifier__stack_size__phrase__phrase_role__special_____phrase___phrase_role__identifier__std__phrase__phrase_role__special______phrase__phrase_role__identifier__size_t__phrase___phrase_role__identifier__next_size__phrase__phrase_role__special_____phrase___phrase_role__identifier__std__phrase__phrase_role__special______phrase__phrase_role__identifier__size_t__phrase___phrase_role__identifier__max_size__phrase__phrase_role__special_____phrase___code_"><code class=
"computeroutput"><span class=
"identifier">basic_pooled_fixedsize_stack
</span><span class=
"special">(
</span><span class=
"identifier">std
</span><span class=
"special">::
</span><span class=
"identifier">size_t
</span>
53 <span class=
"identifier">stack_size
</span><span class=
"special">,
</span>
54 <span class=
"identifier">std
</span><span class=
"special">::
</span><span class=
"identifier">size_t
</span> <span class=
"identifier">next_size
</span><span class=
"special">,
</span> <span class=
"identifier">std
</span><span class=
"special">::
</span><span class=
"identifier">size_t
</span> <span class=
"identifier">max_size
</span><span class=
"special">)
</span></code></a>
56 <div class=
"variablelist">
57 <p class=
"title"><b></b></p>
59 <dt><span class=
"term">Preconditions:
</span></dt>
61 <code class=
"computeroutput"><span class=
"special">!
</span> <span class=
"identifier">traits_type
</span><span class=
"special">::
</span><span class=
"identifier">is_unbounded
</span><span class=
"special">()
</span> <span class=
"special">&&</span>
62 <span class=
"special">(
</span> <span class=
"identifier">traits_type
</span><span class=
"special">::
</span><span class=
"identifier">maximum
</span><span class=
"special">:
</span><span class=
"identifier">size
</span><span class=
"special">()
</span> <span class=
"special">>=
</span> <span class=
"identifier">stack_size
</span><span class=
"special">)
</span></code>
63 and
<code class=
"computeroutput"><span class=
"number">0</span> <span class=
"special"><</span>
64 <span class=
"identifier">nest_size
</span></code>.
66 <dt><span class=
"term">Effects:
</span></dt>
68 Allocates memory of at least
<code class=
"computeroutput"><span class=
"identifier">stack_size
</span></code>
69 Bytes and stores a pointer to the stack and its actual size in
<code class=
"computeroutput"><span class=
"identifier">sctx
</span></code>. Depending on the architecture
70 (the stack grows downwards/upwards) the stored address is the highest/lowest
71 address of the stack. Argument
<code class=
"computeroutput"><span class=
"identifier">next_size
</span></code>
72 determines the number of stacks to request from the system the first
73 time that
<code class=
"computeroutput"><span class=
"special">*
</span><span class=
"keyword">this
</span></code>
74 needs to allocate system memory. The third argument
<code class=
"computeroutput"><span class=
"identifier">max_size
</span></code>
75 controls how many memory might be allocated for stacks - a value of
76 zero means no uper limit.
81 <a name=
"context.stack.pooled_fixedsize.h1"></a>
82 <span><a name=
"context.stack.pooled_fixedsize._code__phrase_role__identifier__stack_context__phrase___phrase_role__identifier__allocate__phrase__phrase_role__special______phrase___code_"></a></span><a class=
"link" href=
"pooled_fixedsize.html#context.stack.pooled_fixedsize._code__phrase_role__identifier__stack_context__phrase___phrase_role__identifier__allocate__phrase__phrase_role__special______phrase___code_"><code class=
"computeroutput"><span class=
"identifier">stack_context
</span> <span class=
"identifier">allocate
</span><span class=
"special">()
</span></code></a>
84 <div class=
"variablelist">
85 <p class=
"title"><b></b></p>
87 <dt><span class=
"term">Preconditions:
</span></dt>
89 <code class=
"computeroutput"><span class=
"special">!
</span> <span class=
"identifier">traits_type
</span><span class=
"special">::
</span><span class=
"identifier">is_unbounded
</span><span class=
"special">()
</span> <span class=
"special">&&</span>
90 <span class=
"special">(
</span> <span class=
"identifier">traits_type
</span><span class=
"special">::
</span><span class=
"identifier">maximum
</span><span class=
"special">:
</span><span class=
"identifier">size
</span><span class=
"special">()
</span> <span class=
"special">>=
</span> <span class=
"identifier">stack_size
</span><span class=
"special">)
</span></code>.
92 <dt><span class=
"term">Effects:
</span></dt>
94 Allocates memory of at least
<code class=
"computeroutput"><span class=
"identifier">stack_size
</span></code>
95 Bytes and stores a pointer to the stack and its actual size in
<code class=
"computeroutput"><span class=
"identifier">sctx
</span></code>. Depending on the architecture
96 (the stack grows downwards/upwards) the stored address is the highest/lowest
102 <a name=
"context.stack.pooled_fixedsize.h2"></a>
103 <span><a name=
"context.stack.pooled_fixedsize._code__phrase_role__keyword__void__phrase___phrase_role__identifier__deallocate__phrase__phrase_role__special_____phrase___phrase_role__identifier__stack_context__phrase___phrase_role__special___amp___phrase___phrase_role__identifier__sctx__phrase__phrase_role__special_____phrase___code_"></a></span><a class=
"link" href=
"pooled_fixedsize.html#context.stack.pooled_fixedsize._code__phrase_role__keyword__void__phrase___phrase_role__identifier__deallocate__phrase__phrase_role__special_____phrase___phrase_role__identifier__stack_context__phrase___phrase_role__special___amp___phrase___phrase_role__identifier__sctx__phrase__phrase_role__special_____phrase___code_"><code class=
"computeroutput"><span class=
"keyword">void
</span> <span class=
"identifier">deallocate
</span><span class=
"special">(
</span> <span class=
"identifier">stack_context
</span>
104 <span class=
"special">&</span> <span class=
"identifier">sctx
</span><span class=
"special">)
</span></code></a>
106 <div class=
"variablelist">
107 <p class=
"title"><b></b></p>
109 <dt><span class=
"term">Preconditions:
</span></dt>
111 <code class=
"computeroutput"><span class=
"identifier">sctx
</span><span class=
"special">.
</span><span class=
"identifier">sp
</span></code> is valid,
<code class=
"computeroutput"><span class=
"special">!
</span>
112 <span class=
"identifier">traits_type
</span><span class=
"special">::
</span><span class=
"identifier">is_unbounded
</span><span class=
"special">()
</span>
113 <span class=
"special">&&</span> <span class=
"special">(
</span>
114 <span class=
"identifier">traits_type
</span><span class=
"special">::
</span><span class=
"identifier">maximum
</span><span class=
"special">:
</span><span class=
"identifier">size
</span><span class=
"special">()
</span>
115 <span class=
"special">>=
</span> <span class=
"identifier">sctx
</span><span class=
"special">.
</span><span class=
"identifier">size
</span><span class=
"special">)
</span></code>.
117 <dt><span class=
"term">Effects:
</span></dt>
119 Deallocates the stack space.
124 <table xmlns:
rev=
"http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width=
"100%"><tr>
125 <td align=
"left"></td>
126 <td align=
"right"><div class=
"copyright-footer">Copyright
© 2014 Oliver Kowalke
<p>
127 Distributed under the Boost Software License, Version
1.0. (See accompanying
128 file LICENSE_1_0.txt or copy at
<a href=
"http://www.boost.org/LICENSE_1_0.txt" target=
"_top">http://www.boost.org/LICENSE_1_0.txt
</a>)
133 <div class=
"spirit-nav">
134 <a accesskey=
"p" href=
"protected_fixedsize.html"><img src=
"../../../../../../doc/src/images/prev.png" alt=
"Prev"></a><a accesskey=
"u" href=
"../stack.html"><img src=
"../../../../../../doc/src/images/up.png" alt=
"Up"></a><a accesskey=
"h" href=
"../../index.html"><img src=
"../../../../../../doc/src/images/home.png" alt=
"Home"></a><a accesskey=
"n" href=
"fixedsize.html"><img src=
"../../../../../../doc/src/images/next.png" alt=
"Next"></a>