3 <meta http-equiv=
"Content-Type" content=
"text/html; charset=US-ASCII">
4 <title>Class segmented_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. Fiber">
8 <link rel=
"up" href=
"../stack.html" title=
"Stack allocation">
9 <link rel=
"prev" href=
"fixedsize.html" title=
"Class fixedsize_stack">
10 <link rel=
"next" href=
"../synchronization.html" title=
"Synchronization">
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=
"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=
"../synchronization.html"><img src=
"../../../../../../doc/src/images/next.png" alt=
"Next"></a>
26 <div class=
"titlepage"><div><div><h3 class=
"title">
27 <a name=
"fiber.stack.segmented_stack"></a><a class=
"link" href=
"segmented_stack.html" title=
"Class segmented_stack">Class
<span class=
"emphasis"><em>segmented_stack
</em></span></a>
28 </h3></div></div></div>
30 <span class=
"bold"><strong>Boost.Fiber
</strong></span> supports usage of a
<a class=
"link" href=
"../../"> <code class=
"computeroutput">segmented_stack
</code></a>,
31 i.e. the stack grows on demand. The fiber is created with a minimal stack
32 size which will be increased as required. Class
<a class=
"link" href=
"../../"> <code class=
"computeroutput">segmented_stack
</code></a> models
33 the
<a class=
"link" href=
"../stack.html#stack_allocator_concept"><span class=
"emphasis"><em>stack-allocator concept
</em></span></a>.
34 In contrast to
<a class=
"link" href=
"../../"> <code class=
"computeroutput">protected_fixedsize_stack
</code></a> and
35 <a class=
"link" href=
"fixedsize.html#class_fixedsize_stack"> <code class=
"computeroutput">fixedsize_stack
</code></a> it creates a stack which grows on demand.
37 <div class=
"note"><table border=
"0" summary=
"Note">
39 <td rowspan=
"2" align=
"center" valign=
"top" width=
"25"><img alt=
"[Note]" src=
"../../../../../../doc/src/images/note.png"></td>
40 <th align=
"left">Note
</th>
42 <tr><td align=
"left" valign=
"top"><p>
43 Segmented stacks are currently only supported by
<span class=
"bold"><strong>gcc
</strong></span>
44 from version
<span class=
"bold"><strong>4.7</strong></span> and
<span class=
"bold"><strong>clang
</strong></span>
45 from version
<span class=
"bold"><strong>3.4</strong></span> onwards. In order to
46 use a
<a class=
"link" href=
"../../"> <code class=
"computeroutput">segmented_stack
</code></a> <span class=
"bold"><strong>Boost.Fiber
</strong></span>
47 must be built with property
<code class=
"computeroutput"><span class=
"identifier">segmented
</span><span class=
"special">-
</span><span class=
"identifier">stacks
</span></code>,
48 e.g.
<span class=
"bold"><strong>toolset=gcc segmented-stacks=on
</strong></span> at
52 <pre class=
"programlisting"><span class=
"preprocessor">#include
</span> <span class=
"special"><</span><span class=
"identifier">boost
</span><span class=
"special">/
</span><span class=
"identifier">fiber
</span><span class=
"special">/
</span><span class=
"identifier">segmented_stack
</span><span class=
"special">.
</span><span class=
"identifier">hpp
</span><span class=
"special">></span>
54 <span class=
"keyword">struct
</span> <span class=
"identifier">segmented_stack
</span> <span class=
"special">{
</span>
55 <span class=
"identifier">segmented_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>
57 <span class=
"identifier">stack_context
</span> <span class=
"identifier">allocate
</span><span class=
"special">();
</span>
59 <span class=
"keyword">void
</span> <span class=
"identifier">deallocate
</span><span class=
"special">(
</span> <span class=
"identifier">stack_context
</span> <span class=
"special">&);
</span>
60 <span class=
"special">}
</span>
63 <a name=
"fiber.stack.segmented_stack.h0"></a>
64 <span><a name=
"fiber.stack.segmented_stack._code__phrase_role__identifier__stack_context__phrase___phrase_role__identifier__allocate__phrase__phrase_role__special______phrase___code_"></a></span><a class=
"link" href=
"segmented_stack.html#fiber.stack.segmented_stack._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>
66 <div class=
"variablelist">
67 <p class=
"title"><b></b></p>
69 <dt><span class=
"term">Preconditions:
</span></dt>
71 <code class=
"computeroutput"><span class=
"identifier">traits_type
</span><span class=
"special">::
</span><span class=
"identifier">minimum_size
</span><span class=
"special">()
</span>
72 <span class=
"special"><=
</span> <span class=
"identifier">size
</span></code>
73 and
<code class=
"computeroutput"><span class=
"identifier">traits_type
</span><span class=
"special">::
</span><span class=
"identifier">is_unbounded
</span><span class=
"special">()
</span>
74 <span class=
"special">||
</span> <span class=
"special">(
</span>
75 <span class=
"identifier">traits_type
</span><span class=
"special">::
</span><span class=
"identifier">maximum_size
</span><span class=
"special">()
</span>
76 <span class=
"special">>=
</span> <span class=
"identifier">size
</span><span class=
"special">)
</span></code>.
78 <dt><span class=
"term">Effects:
</span></dt>
80 Allocates memory of at least
<code class=
"computeroutput"><span class=
"identifier">size
</span></code>
81 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
82 (the stack grows downwards/upwards) the stored address is the highest/lowest
88 <a name=
"fiber.stack.segmented_stack.h1"></a>
89 <span><a name=
"fiber.stack.segmented_stack._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=
"segmented_stack.html#fiber.stack.segmented_stack._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>
90 <span class=
"special">&</span> <span class=
"identifier">sctx
</span><span class=
"special">)
</span></code></a>
92 <div class=
"variablelist">
93 <p class=
"title"><b></b></p>
95 <dt><span class=
"term">Preconditions:
</span></dt>
97 <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=
"identifier">traits_type
</span><span class=
"special">::
</span><span class=
"identifier">minimum_size
</span><span class=
"special">()
</span> <span class=
"special"><=
</span> <span class=
"identifier">sctx
</span><span class=
"special">.
</span><span class=
"identifier">size
</span></code> and
<code class=
"computeroutput"><span class=
"identifier">traits_type
</span><span class=
"special">::
</span><span class=
"identifier">is_unbounded
</span><span class=
"special">()
</span> <span class=
"special">||
</span> <span class=
"special">(
</span> <span class=
"identifier">traits_type
</span><span class=
"special">::
</span><span class=
"identifier">maximum_size
</span><span class=
"special">()
</span> <span class=
"special">>=
</span> <span class=
"identifier">sctx
</span><span class=
"special">.
</span><span class=
"identifier">size
</span><span class=
"special">)
</span></code>.
99 <dt><span class=
"term">Effects:
</span></dt>
101 Deallocates the stack space.
105 <div class=
"note"><table border=
"0" summary=
"Note">
107 <td rowspan=
"2" align=
"center" valign=
"top" width=
"25"><img alt=
"[Note]" src=
"../../../../../../doc/src/images/note.png"></td>
108 <th align=
"left">Note
</th>
110 <tr><td align=
"left" valign=
"top"><p>
111 If the library is compiled for segmented stacks,
<a class=
"link" href=
"../../"> <code class=
"computeroutput">segmented_stack
</code></a> is
112 the only available stack allocator.
116 <table xmlns:
rev=
"http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width=
"100%"><tr>
117 <td align=
"left"></td>
118 <td align=
"right"><div class=
"copyright-footer">Copyright
© 2013 Oliver Kowalke
<p>
119 Distributed under the Boost Software License, Version
1.0. (See accompanying
120 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>)
125 <div class=
"spirit-nav">
126 <a accesskey=
"p" href=
"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=
"../synchronization.html"><img src=
"../../../../../../doc/src/images/next.png" alt=
"Next"></a>