]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | <html> |
2 | <head> | |
3 | <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> | |
4 | <title>Class protected_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. Fiber"> | |
8 | <link rel="up" href="../stack.html" title="Stack allocation"> | |
9 | <link rel="prev" href="../stack.html" title="Stack allocation"> | |
10 | <link rel="next" href="pooled_fixedsize.html" title="Class pooled_fixedsize_stack"> | |
11 | </head> | |
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> | |
20 | </tr></table> | |
21 | <hr> | |
22 | <div class="spirit-nav"> | |
23 | <a accesskey="p" href="../stack.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="pooled_fixedsize.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> | |
24 | </div> | |
25 | <div class="section"> | |
26 | <div class="titlepage"><div><div><h3 class="title"> | |
27 | <a name="fiber.stack.protected_fixedsize"></a><a class="link" href="protected_fixedsize.html" title="Class protected_fixedsize_stack">Class <span class="emphasis"><em>protected_fixedsize_stack</em></span></a> | |
28 | </h3></div></div></div> | |
29 | <p> | |
30 | <span class="bold"><strong>Boost.Fiber</strong></span> provides the class <a class="link" href="../../"> <code class="computeroutput">protected_fixedsize_stack</code></a> which | |
31 | models the <a class="link" href="../stack.html#stack_allocator_concept"><span class="emphasis"><em>stack-allocator | |
32 | concept</em></span></a>. It appends a guard page at the end of each stack | |
33 | to protect against exceeding the stack. If the guard page is accessed (read | |
34 | or write operation) a segmentation fault/access violation is generated by | |
35 | the operating system. | |
36 | </p> | |
37 | <div class="important"><table border="0" summary="Important"> | |
38 | <tr> | |
39 | <td rowspan="2" align="center" valign="top" width="25"><img alt="[Important]" src="../../../../../../doc/src/images/important.png"></td> | |
40 | <th align="left">Important</th> | |
41 | </tr> | |
42 | <tr><td align="left" valign="top"><p> | |
43 | Using <a class="link" href="../../"> <code class="computeroutput">protected_fixedsize_stack</code></a> is expensive. | |
44 | Launching a new fiber with a stack of this type incurs the overhead of | |
45 | setting the memory protection; once allocated, this stack is just as efficient | |
46 | to use as <a class="link" href="fixedsize.html#class_fixedsize_stack"> <code class="computeroutput">fixedsize_stack</code></a>. | |
47 | </p></td></tr> | |
48 | </table></div> | |
49 | <div class="note"><table border="0" summary="Note"> | |
50 | <tr> | |
51 | <td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../doc/src/images/note.png"></td> | |
52 | <th align="left">Note</th> | |
53 | </tr> | |
54 | <tr><td align="left" valign="top"><p> | |
55 | The appended <code class="computeroutput"><span class="identifier">guard</span> <span class="identifier">page</span></code> | |
56 | is <span class="bold"><strong>not</strong></span> mapped to physical memory, only | |
57 | virtual addresses are used. | |
58 | </p></td></tr> | |
59 | </table></div> | |
60 | <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">protected_fixedsize</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> | |
61 | ||
62 | <span class="keyword">struct</span> <span class="identifier">protected_fixedsize</span> <span class="special">{</span> | |
63 | <span class="identifier">protected_fixesize</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">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> | |
64 | ||
65 | <span class="identifier">stack_context</span> <span class="identifier">allocate</span><span class="special">();</span> | |
66 | ||
67 | <span class="keyword">void</span> <span class="identifier">deallocate</span><span class="special">(</span> <span class="identifier">stack_context</span> <span class="special">&);</span> | |
68 | <span class="special">}</span> | |
69 | </pre> | |
70 | <h5> | |
71 | <a name="fiber.stack.protected_fixedsize.h0"></a> | |
72 | <span><a name="fiber.stack.protected_fixedsize._code__phrase_role__identifier__stack_context__phrase___phrase_role__identifier__allocate__phrase__phrase_role__special______phrase___code_"></a></span><a class="link" href="protected_fixedsize.html#fiber.stack.protected_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> | |
73 | </h5> | |
74 | <div class="variablelist"> | |
75 | <p class="title"><b></b></p> | |
76 | <dl> | |
77 | <dt><span class="term">Preconditions:</span></dt> | |
78 | <dd><p> | |
79 | <code class="computeroutput"><span class="identifier">traits_type</span><span class="special">::</span><span class="identifier">minimum_size</span><span class="special">()</span> | |
80 | <span class="special"><=</span> <span class="identifier">size</span></code> | |
81 | and <code class="computeroutput"><span class="identifier">traits_type</span><span class="special">::</span><span class="identifier">is_unbounded</span><span class="special">()</span> | |
82 | <span class="special">||</span> <span class="special">(</span> | |
83 | <span class="identifier">size</span> <span class="special"><=</span> | |
84 | <span class="identifier">traits_type</span><span class="special">::</span><span class="identifier">maximum_size</span><span class="special">()</span> | |
85 | <span class="special">)</span></code>. | |
86 | </p></dd> | |
87 | <dt><span class="term">Effects:</span></dt> | |
88 | <dd><p> | |
89 | Allocates memory of at least <code class="computeroutput"><span class="identifier">size</span></code> | |
90 | 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 | |
91 | (the stack grows downwards/upwards) the stored address is the highest/lowest | |
92 | address of the stack. | |
93 | </p></dd> | |
94 | </dl> | |
95 | </div> | |
96 | <h5> | |
97 | <a name="fiber.stack.protected_fixedsize.h1"></a> | |
98 | <span><a name="fiber.stack.protected_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="protected_fixedsize.html#fiber.stack.protected_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> | |
99 | <span class="special">&</span> <span class="identifier">sctx</span><span class="special">)</span></code></a> | |
100 | </h5> | |
101 | <div class="variablelist"> | |
102 | <p class="title"><b></b></p> | |
103 | <dl> | |
104 | <dt><span class="term">Preconditions:</span></dt> | |
105 | <dd><p> | |
106 | <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">sctx</span><span class="special">.</span><span class="identifier">size</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></code>. | |
107 | </p></dd> | |
108 | <dt><span class="term">Effects:</span></dt> | |
109 | <dd><p> | |
110 | Deallocates the stack space. | |
111 | </p></dd> | |
112 | </dl> | |
113 | </div> | |
114 | </div> | |
115 | <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> | |
116 | <td align="left"></td> | |
117 | <td align="right"><div class="copyright-footer">Copyright © 2013 Oliver Kowalke<p> | |
118 | Distributed under the Boost Software License, Version 1.0. (See accompanying | |
119 | 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>) | |
120 | </p> | |
121 | </div></td> | |
122 | </tr></table> | |
123 | <hr> | |
124 | <div class="spirit-nav"> | |
125 | <a accesskey="p" href="../stack.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="pooled_fixedsize.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> | |
126 | </div> | |
127 | </body> | |
128 | </html> |