• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4<title>Future</title>
5<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css">
6<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
7<link rel="home" href="../../../index.html" title="Chapter 1. Fiber">
8<link rel="up" href="../futures.html" title="Futures">
9<link rel="prev" href="../futures.html" title="Futures">
10<link rel="next" href="promise.html" title="Template promise&lt;&gt;">
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="../futures.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../futures.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="promise.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
24</div>
25<div class="section">
26<div class="titlepage"><div><div><h4 class="title">
27<a name="fiber.synchronization.futures.future"></a><a class="link" href="future.html" title="Future">Future</a>
28</h4></div></div></div>
29<p>
30          A future provides a mechanism to access the result of an asynchronous operation.
31        </p>
32<a name="shared_state"></a><h6>
33<a name="fiber.synchronization.futures.future.h0"></a>
34          <span class="phrase"><a name="fiber.synchronization.futures.future.shared_state"></a></span><a class="link" href="future.html#fiber.synchronization.futures.future.shared_state">shared
35          state</a>
36        </h6>
37<p>
38          Behind a <a class="link" href="promise.html#class_promise"><code class="computeroutput">promise&lt;&gt;</code></a> and its <a class="link" href="future.html#class_future"><code class="computeroutput">future&lt;&gt;</code></a> lies
39          an unspecified object called their <span class="emphasis"><em>shared state</em></span>. The
40          shared state is what will actually hold the async result (or the exception).
41        </p>
42<p>
43          The shared state is instantiated along with the <a class="link" href="promise.html#class_promise"><code class="computeroutput">promise&lt;&gt;</code></a>.
44        </p>
45<p>
46          Aside from its originating <code class="computeroutput"><span class="identifier">promise</span><span class="special">&lt;&gt;</span></code>, a <a class="link" href="future.html#class_future"><code class="computeroutput">future&lt;&gt;</code></a> holds
47          a unique reference to a particular shared state. However, multiple <a class="link" href="future.html#class_shared_future"><code class="computeroutput">shared_future&lt;&gt;</code></a> instances
48          can reference the same underlying shared state.
49        </p>
50<p>
51          As <a class="link" href="packaged_task.html#class_packaged_task"><code class="computeroutput">packaged_task&lt;&gt;</code></a> and <a class="link" href="future.html#fibers_async"><code class="computeroutput">fibers::async()</code></a> are
52          implemented using <a class="link" href="promise.html#class_promise"><code class="computeroutput">promise&lt;&gt;</code></a>, discussions of shared state
53          apply to them as well.
54        </p>
55<a name="class_future_status"></a><h6>
56<a name="fiber.synchronization.futures.future.h1"></a>
57          <span class="phrase"><a name="fiber.synchronization.futures.future.enumeration__code__phrase_role__identifier__future_status__phrase___code_"></a></span><a class="link" href="future.html#fiber.synchronization.futures.future.enumeration__code__phrase_role__identifier__future_status__phrase___code_">Enumeration
58          <code class="computeroutput"><span class="identifier">future_status</span></code></a>
59        </h6>
60<p>
61          Timed wait-operations (<a class="link" href="future.html#future_wait_for"><code class="computeroutput">future::wait_for()</code></a> and <a class="link" href="future.html#future_wait_until"><code class="computeroutput">future::wait_until()</code></a>)
62          return the state of the future.
63        </p>
64<pre class="programlisting"><span class="keyword">enum</span> <span class="keyword">class</span> <span class="identifier">future_status</span> <span class="special">{</span>
65    <span class="identifier">ready</span><span class="special">,</span>
66    <span class="identifier">timeout</span><span class="special">,</span>
67    <span class="identifier">deferred</span>  <span class="comment">// not supported yet</span>
68<span class="special">};</span>
69</pre>
70<h6>
71<a name="fiber.synchronization.futures.future.h2"></a>
72          <span class="phrase"><a name="fiber.synchronization.futures.future._code__phrase_role__identifier__ready__phrase___code_"></a></span><a class="link" href="future.html#fiber.synchronization.futures.future._code__phrase_role__identifier__ready__phrase___code_"><code class="computeroutput"><span class="identifier">ready</span></code></a>
73        </h6>
74<div class="variablelist">
75<p class="title"><b></b></p>
76<dl class="variablelist">
77<dt><span class="term">Effects:</span></dt>
78<dd><p>
79                The <a class="link" href="future.html#shared_state">shared state</a> is ready.
80              </p></dd>
81</dl>
82</div>
83<h6>
84<a name="fiber.synchronization.futures.future.h3"></a>
85          <span class="phrase"><a name="fiber.synchronization.futures.future._code__phrase_role__identifier__timeout__phrase___code_"></a></span><a class="link" href="future.html#fiber.synchronization.futures.future._code__phrase_role__identifier__timeout__phrase___code_"><code class="computeroutput"><span class="identifier">timeout</span></code></a>
86        </h6>
87<div class="variablelist">
88<p class="title"><b></b></p>
89<dl class="variablelist">
90<dt><span class="term">Effects:</span></dt>
91<dd><p>
92                The <a class="link" href="future.html#shared_state">shared state</a> did not become
93                ready before timeout has passed.
94              </p></dd>
95</dl>
96</div>
97<div class="note"><table border="0" summary="Note">
98<tr>
99<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../../doc/src/images/note.png"></td>
100<th align="left">Note</th>
101</tr>
102<tr><td align="left" valign="top"><p>
103            Deferred futures are not supported.
104          </p></td></tr>
105</table></div>
106<p>
107          </p>
108<h5>
109<a name="class_future_bridgehead"></a>
110  <span class="phrase"><a name="class_future"></a></span>
111  <a class="link" href="future.html#class_future">Template <code class="computeroutput">future&lt;&gt;</code></a>
112</h5>
113<p>
114        </p>
115<p>
116          A <a class="link" href="future.html#class_future"><code class="computeroutput">future&lt;&gt;</code></a> contains a <a class="link" href="future.html#shared_state">shared
117          state</a> which is not shared with any other future.
118        </p>
119<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">fiber</span><span class="special">/</span><span class="identifier">future</span><span class="special">/</span><span class="identifier">future</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
120
121<span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span>
122<span class="keyword">namespace</span> <span class="identifier">fibers</span> <span class="special">{</span>
123
124<span class="keyword">template</span><span class="special">&lt;</span> <span class="keyword">typename</span> <span class="identifier">R</span> <span class="special">&gt;</span>
125<span class="keyword">class</span> <span class="identifier">future</span> <span class="special">{</span>
126<span class="keyword">public</span><span class="special">:</span>
127    <span class="identifier">future</span><span class="special">()</span> <span class="keyword">noexcept</span><span class="special">;</span>
128
129    <span class="identifier">future</span><span class="special">(</span> <span class="identifier">future</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">other</span><span class="special">)</span> <span class="special">=</span> <span class="keyword">delete</span><span class="special">;</span>
130
131    <span class="identifier">future</span> <span class="special">&amp;</span> <span class="keyword">operator</span><span class="special">=(</span> <span class="identifier">future</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">other</span><span class="special">)</span> <span class="special">=</span> <span class="keyword">delete</span><span class="special">;</span>
132
133    <span class="identifier">future</span><span class="special">(</span> <span class="identifier">future</span> <span class="special">&amp;&amp;</span> <span class="identifier">other</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span>
134
135    <span class="identifier">future</span> <span class="special">&amp;</span> <span class="keyword">operator</span><span class="special">=(</span> <span class="identifier">future</span> <span class="special">&amp;&amp;</span> <span class="identifier">other</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span>
136
137    <span class="special">~</span><span class="identifier">future</span><span class="special">();</span>
138
139    <span class="keyword">bool</span> <span class="identifier">valid</span><span class="special">()</span> <span class="keyword">const</span> <span class="keyword">noexcept</span><span class="special">;</span>
140
141    <span class="identifier">shared_future</span><span class="special">&lt;</span> <span class="identifier">R</span> <span class="special">&gt;</span> <span class="identifier">share</span><span class="special">();</span>
142
143    <span class="identifier">R</span> <span class="identifier">get</span><span class="special">();</span>    <span class="comment">// member only of generic future template</span>
144    <span class="identifier">R</span> <span class="special">&amp;</span> <span class="identifier">get</span><span class="special">();</span>  <span class="comment">// member only of future&lt; R &amp; &gt; template specialization</span>
145    <span class="keyword">void</span> <span class="identifier">get</span><span class="special">();</span> <span class="comment">// member only of future&lt; void &gt; template specialization</span>
146
147    <span class="identifier">std</span><span class="special">::</span><span class="identifier">exception_ptr</span> <span class="identifier">get_exception_ptr</span><span class="special">();</span>
148
149    <span class="keyword">void</span> <span class="identifier">wait</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
150
151    <span class="keyword">template</span><span class="special">&lt;</span> <span class="keyword">class</span> <span class="identifier">Rep</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Period</span> <span class="special">&gt;</span>
152    <span class="identifier">future_status</span> <span class="identifier">wait_for</span><span class="special">(</span>
153        <span class="identifier">std</span><span class="special">::</span><span class="identifier">chrono</span><span class="special">::</span><span class="identifier">duration</span><span class="special">&lt;</span> <span class="identifier">Rep</span><span class="special">,</span> <span class="identifier">Period</span> <span class="special">&gt;</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">timeout_duration</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
154
155    <span class="keyword">template</span><span class="special">&lt;</span> <span class="keyword">typename</span> <span class="identifier">Clock</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">Duration</span> <span class="special">&gt;</span>
156    <span class="identifier">future_status</span> <span class="identifier">wait_until</span><span class="special">(</span>
157        <span class="identifier">std</span><span class="special">::</span><span class="identifier">chrono</span><span class="special">::</span><span class="identifier">time_point</span><span class="special">&lt;</span> <span class="identifier">Clock</span><span class="special">,</span> <span class="identifier">Duration</span> <span class="special">&gt;</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">timeout_time</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
158<span class="special">};</span>
159
160<span class="special">}}</span>
161</pre>
162<h6>
163<a name="fiber.synchronization.futures.future.h4"></a>
164          <span class="phrase"><a name="fiber.synchronization.futures.future.default_constructor"></a></span><a class="link" href="future.html#fiber.synchronization.futures.future.default_constructor">Default
165          constructor</a>
166        </h6>
167<pre class="programlisting"><span class="identifier">future</span><span class="special">()</span> <span class="keyword">noexcept</span><span class="special">;</span>
168</pre>
169<div class="variablelist">
170<p class="title"><b></b></p>
171<dl class="variablelist">
172<dt><span class="term">Effects:</span></dt>
173<dd><p>
174                Creates a future with no <a class="link" href="future.html#shared_state">shared state</a>.
175                After construction <code class="computeroutput"><span class="keyword">false</span> <span class="special">==</span> <span class="identifier">valid</span><span class="special">()</span></code>.
176              </p></dd>
177<dt><span class="term">Throws:</span></dt>
178<dd><p>
179                Nothing.
180              </p></dd>
181</dl>
182</div>
183<h6>
184<a name="fiber.synchronization.futures.future.h5"></a>
185          <span class="phrase"><a name="fiber.synchronization.futures.future.move_constructor"></a></span><a class="link" href="future.html#fiber.synchronization.futures.future.move_constructor">Move constructor</a>
186        </h6>
187<pre class="programlisting"><span class="identifier">future</span><span class="special">(</span> <span class="identifier">future</span> <span class="special">&amp;&amp;</span> <span class="identifier">other</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span>
188</pre>
189<div class="variablelist">
190<p class="title"><b></b></p>
191<dl class="variablelist">
192<dt><span class="term">Effects:</span></dt>
193<dd><p>
194                Constructs a future with the <a class="link" href="future.html#shared_state">shared
195                state</a> of other. After construction <code class="computeroutput"><span class="keyword">false</span>
196                <span class="special">==</span> <span class="identifier">other</span><span class="special">.</span><span class="identifier">valid</span><span class="special">()</span></code>.
197              </p></dd>
198<dt><span class="term">Throws:</span></dt>
199<dd><p>
200                Nothing.
201              </p></dd>
202</dl>
203</div>
204<h6>
205<a name="fiber.synchronization.futures.future.h6"></a>
206          <span class="phrase"><a name="fiber.synchronization.futures.future.destructor"></a></span><a class="link" href="future.html#fiber.synchronization.futures.future.destructor">Destructor</a>
207        </h6>
208<pre class="programlisting"><span class="special">~</span><span class="identifier">future</span><span class="special">();</span>
209</pre>
210<div class="variablelist">
211<p class="title"><b></b></p>
212<dl class="variablelist">
213<dt><span class="term">Effects:</span></dt>
214<dd><p>
215                Destroys the future; ownership is abandoned.
216              </p></dd>
217<dt><span class="term">Note:</span></dt>
218<dd><p>
219                <code class="computeroutput">~future()</code> does <span class="emphasis"><em>not</em></span> block the calling fiber.
220              </p></dd>
221</dl>
222</div>
223<p>
224          Consider a sequence such as:
225        </p>
226<div class="orderedlist"><ol class="orderedlist" type="1">
227<li class="listitem">
228              instantiate <a class="link" href="promise.html#class_promise"><code class="computeroutput">promise&lt;&gt;</code></a>
229            </li>
230<li class="listitem">
231              obtain its <code class="computeroutput"><span class="identifier">future</span><span class="special">&lt;&gt;</span></code>
232              via <a class="link" href="promise.html#promise_get_future"><code class="computeroutput">promise::get_future()</code></a>
233            </li>
234<li class="listitem">
235              launch <a class="link" href="../../fiber_mgmt/fiber.html#class_fiber"><code class="computeroutput">fiber</code></a>, capturing <code class="computeroutput"><span class="identifier">promise</span><span class="special">&lt;&gt;</span></code>
236            </li>
237<li class="listitem">
238              destroy <code class="computeroutput"><span class="identifier">future</span><span class="special">&lt;&gt;</span></code>
239            </li>
240<li class="listitem">
241              call <a class="link" href="promise.html#promise_set_value"><code class="computeroutput">promise::set_value()</code></a>
242            </li>
243</ol></div>
244<p>
245          The final <code class="computeroutput"><span class="identifier">set_value</span><span class="special">()</span></code>
246          call succeeds, but the value is silently discarded: no additional <code class="computeroutput"><span class="identifier">future</span><span class="special">&lt;&gt;</span></code>
247          can be obtained from that <code class="computeroutput"><span class="identifier">promise</span><span class="special">&lt;&gt;</span></code>.
248        </p>
249<p>
250          </p>
251<h5>
252<a name="future_operator_assign_bridgehead"></a>
253  <span class="phrase"><a name="future_operator_assign"></a></span>
254  <a class="link" href="future.html#future_operator_assign">Member
255          function <code class="computeroutput">operator=</code>()</a>
256</h5>
257<p>
258        </p>
259<pre class="programlisting"><span class="identifier">future</span> <span class="special">&amp;</span> <span class="keyword">operator</span><span class="special">=(</span> <span class="identifier">future</span> <span class="special">&amp;&amp;</span> <span class="identifier">other</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span>
260</pre>
261<div class="variablelist">
262<p class="title"><b></b></p>
263<dl class="variablelist">
264<dt><span class="term">Effects:</span></dt>
265<dd><p>
266                Moves the <a class="link" href="future.html#shared_state">shared state</a> of other
267                to <code class="computeroutput"><span class="keyword">this</span></code>. After the assignment,
268                <code class="computeroutput"><span class="keyword">false</span> <span class="special">==</span>
269                <span class="identifier">other</span><span class="special">.</span><span class="identifier">valid</span><span class="special">()</span></code>.
270              </p></dd>
271<dt><span class="term">Throws:</span></dt>
272<dd><p>
273                Nothing.
274              </p></dd>
275</dl>
276</div>
277<p>
278          </p>
279<h5>
280<a name="future_valid_bridgehead"></a>
281  <span class="phrase"><a name="future_valid"></a></span>
282  <a class="link" href="future.html#future_valid">Member function <code class="computeroutput">valid</code>()</a>
283</h5>
284<p>
285        </p>
286<pre class="programlisting"><span class="keyword">bool</span> <span class="identifier">valid</span><span class="special">()</span> <span class="keyword">const</span> <span class="keyword">noexcept</span><span class="special">;</span>
287</pre>
288<div class="variablelist">
289<p class="title"><b></b></p>
290<dl class="variablelist">
291<dt><span class="term">Effects:</span></dt>
292<dd><p>
293                Returns <code class="computeroutput"><span class="keyword">true</span></code> if future
294                contains a <a class="link" href="future.html#shared_state">shared state</a>.
295              </p></dd>
296<dt><span class="term">Throws:</span></dt>
297<dd><p>
298                Nothing.
299              </p></dd>
300</dl>
301</div>
302<p>
303          </p>
304<h5>
305<a name="future_share_bridgehead"></a>
306  <span class="phrase"><a name="future_share"></a></span>
307  <a class="link" href="future.html#future_share">Member function <code class="computeroutput">share</code>()</a>
308</h5>
309<p>
310        </p>
311<pre class="programlisting"><span class="identifier">shared_future</span><span class="special">&lt;</span> <span class="identifier">R</span> <span class="special">&gt;</span> <span class="identifier">share</span><span class="special">();</span>
312</pre>
313<div class="variablelist">
314<p class="title"><b></b></p>
315<dl class="variablelist">
316<dt><span class="term">Effects:</span></dt>
317<dd><p>
318                Move the state to a <a class="link" href="future.html#class_shared_future"><code class="computeroutput">shared_future&lt;&gt;</code></a>.
319              </p></dd>
320<dt><span class="term">Returns:</span></dt>
321<dd><p>
322                a <a class="link" href="future.html#class_shared_future"><code class="computeroutput">shared_future&lt;&gt;</code></a> containing the <a class="link" href="future.html#shared_state">shared
323                state</a> formerly belonging to <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>.
324              </p></dd>
325<dt><span class="term">Postcondition:</span></dt>
326<dd><p>
327                <code class="computeroutput"><span class="keyword">false</span> <span class="special">==</span>
328                <span class="identifier">valid</span><span class="special">()</span></code>
329              </p></dd>
330<dt><span class="term">Throws:</span></dt>
331<dd><p>
332                <code class="computeroutput"><span class="identifier">future_error</span></code> with
333                error condition <code class="computeroutput"><span class="identifier">future_errc</span><span class="special">::</span><span class="identifier">no_state</span></code>.
334              </p></dd>
335</dl>
336</div>
337<p>
338          </p>
339<h5>
340<a name="future_get_bridgehead"></a>
341  <span class="phrase"><a name="future_get"></a></span>
342  <a class="link" href="future.html#future_get">Member function <code class="computeroutput">get</code>()</a>
343</h5>
344<p>
345        </p>
346<pre class="programlisting"><span class="identifier">R</span> <span class="identifier">get</span><span class="special">();</span>    <span class="comment">// member only of generic future template</span>
347<span class="identifier">R</span> <span class="special">&amp;</span> <span class="identifier">get</span><span class="special">();</span>  <span class="comment">// member only of future&lt; R &amp; &gt; template specialization</span>
348<span class="keyword">void</span> <span class="identifier">get</span><span class="special">();</span> <span class="comment">// member only of future&lt; void &gt; template specialization</span>
349</pre>
350<div class="variablelist">
351<p class="title"><b></b></p>
352<dl class="variablelist">
353<dt><span class="term">Precondition:</span></dt>
354<dd><p>
355                <code class="computeroutput"><span class="keyword">true</span> <span class="special">==</span>
356                <span class="identifier">valid</span><span class="special">()</span></code>
357              </p></dd>
358<dt><span class="term">Returns:</span></dt>
359<dd><p>
360                Waits until <a class="link" href="promise.html#promise_set_value"><code class="computeroutput">promise::set_value()</code></a> or <a class="link" href="promise.html#promise_set_exception"><code class="computeroutput">promise::set_exception()</code></a> is
361                called. If <a class="link" href="promise.html#promise_set_value"><code class="computeroutput">promise::set_value()</code></a> is called, returns
362                the value. If <a class="link" href="promise.html#promise_set_exception"><code class="computeroutput">promise::set_exception()</code></a> is called,
363                throws the indicated exception.
364              </p></dd>
365<dt><span class="term">Postcondition:</span></dt>
366<dd><p>
367                <code class="computeroutput"><span class="keyword">false</span> <span class="special">==</span>
368                <span class="identifier">valid</span><span class="special">()</span></code>
369              </p></dd>
370<dt><span class="term">Throws:</span></dt>
371<dd><p>
372                <code class="computeroutput"><span class="identifier">future_error</span></code> with
373                error condition <code class="computeroutput"><span class="identifier">future_errc</span><span class="special">::</span><span class="identifier">no_state</span></code>,
374                <code class="computeroutput"><span class="identifier">future_errc</span><span class="special">::</span><span class="identifier">broken_promise</span></code>. Any exception passed
375                to <code class="computeroutput"><span class="identifier">promise</span><span class="special">::</span><span class="identifier">set_exception</span><span class="special">()</span></code>.
376              </p></dd>
377</dl>
378</div>
379<p>
380          </p>
381<h5>
382<a name="future_get_exception_ptr_bridgehead"></a>
383  <span class="phrase"><a name="future_get_exception_ptr"></a></span>
384  <a class="link" href="future.html#future_get_exception_ptr">Member
385          function <code class="computeroutput">get_exception_ptr</code>()</a>
386</h5>
387<p>
388        </p>
389<pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">exception_ptr</span> <span class="identifier">get_exception_ptr</span><span class="special">();</span>
390</pre>
391<div class="variablelist">
392<p class="title"><b></b></p>
393<dl class="variablelist">
394<dt><span class="term">Precondition:</span></dt>
395<dd><p>
396                <code class="computeroutput"><span class="keyword">true</span> <span class="special">==</span>
397                <span class="identifier">valid</span><span class="special">()</span></code>
398              </p></dd>
399<dt><span class="term">Returns:</span></dt>
400<dd><p>
401                Waits until <a class="link" href="promise.html#promise_set_value"><code class="computeroutput">promise::set_value()</code></a> or <a class="link" href="promise.html#promise_set_exception"><code class="computeroutput">promise::set_exception()</code></a> is
402                called. If <code class="computeroutput"><span class="identifier">set_value</span><span class="special">()</span></code> is called, returns a default-constructed
403                <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">exception_ptr</span></code>. If <code class="computeroutput"><span class="identifier">set_exception</span><span class="special">()</span></code>
404                is called, returns the passed <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">exception_ptr</span></code>.
405              </p></dd>
406<dt><span class="term">Throws:</span></dt>
407<dd><p>
408                <code class="computeroutput"><span class="identifier">future_error</span></code> with
409                error condition <code class="computeroutput"><span class="identifier">future_errc</span><span class="special">::</span><span class="identifier">no_state</span></code>.
410              </p></dd>
411<dt><span class="term">Note:</span></dt>
412<dd><p>
413                <code class="computeroutput"><span class="identifier">get_exception_ptr</span><span class="special">()</span></code> does <span class="emphasis"><em>not</em></span> invalidate
414                the <code class="computeroutput">future</code>. After calling <code class="computeroutput"><span class="identifier">get_exception_ptr</span><span class="special">()</span></code>, you may still call <a class="link" href="future.html#future_get"><code class="computeroutput">future::get()</code></a>.
415              </p></dd>
416</dl>
417</div>
418<p>
419          </p>
420<h5>
421<a name="future_wait_bridgehead"></a>
422  <span class="phrase"><a name="future_wait"></a></span>
423  <a class="link" href="future.html#future_wait">Member function <code class="computeroutput">wait</code>()</a>
424</h5>
425<p>
426        </p>
427<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">wait</span><span class="special">();</span>
428</pre>
429<div class="variablelist">
430<p class="title"><b></b></p>
431<dl class="variablelist">
432<dt><span class="term">Effects:</span></dt>
433<dd><p>
434                Waits until <a class="link" href="promise.html#promise_set_value"><code class="computeroutput">promise::set_value()</code></a> or <a class="link" href="promise.html#promise_set_exception"><code class="computeroutput">promise::set_exception()</code></a> is
435                called.
436              </p></dd>
437<dt><span class="term">Throws:</span></dt>
438<dd><p>
439                <code class="computeroutput"><span class="identifier">future_error</span></code> with
440                error condition <code class="computeroutput"><span class="identifier">future_errc</span><span class="special">::</span><span class="identifier">no_state</span></code>.
441              </p></dd>
442</dl>
443</div>
444<p>
445          </p>
446<h5>
447<a name="future_wait_for_bridgehead"></a>
448  <span class="phrase"><a name="future_wait_for"></a></span>
449  <a class="link" href="future.html#future_wait_for">Templated member
450          function <code class="computeroutput">wait_for</code>()</a>
451</h5>
452<p>
453        </p>
454<pre class="programlisting"><span class="keyword">template</span><span class="special">&lt;</span> <span class="keyword">class</span> <span class="identifier">Rep</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Period</span> <span class="special">&gt;</span>
455<span class="identifier">future_status</span> <span class="identifier">wait_for</span><span class="special">(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">chrono</span><span class="special">::</span><span class="identifier">duration</span><span class="special">&lt;</span> <span class="identifier">Rep</span><span class="special">,</span> <span class="identifier">Period</span> <span class="special">&gt;</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">timeout_duration</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
456</pre>
457<div class="variablelist">
458<p class="title"><b></b></p>
459<dl class="variablelist">
460<dt><span class="term">Effects:</span></dt>
461<dd><p>
462                Waits until <a class="link" href="promise.html#promise_set_value"><code class="computeroutput">promise::set_value()</code></a> or <a class="link" href="promise.html#promise_set_exception"><code class="computeroutput">promise::set_exception()</code></a> is
463                called, or <code class="computeroutput"><span class="identifier">timeout_duration</span></code>
464                has passed.
465              </p></dd>
466<dt><span class="term">Result:</span></dt>
467<dd><p>
468                A <code class="computeroutput"><span class="identifier">future_status</span></code> is
469                returned indicating the reason for returning.
470              </p></dd>
471<dt><span class="term">Throws:</span></dt>
472<dd><p>
473                <code class="computeroutput"><span class="identifier">future_error</span></code> with
474                error condition <code class="computeroutput"><span class="identifier">future_errc</span><span class="special">::</span><span class="identifier">no_state</span></code>
475                or timeout-related exceptions.
476              </p></dd>
477</dl>
478</div>
479<p>
480          </p>
481<h5>
482<a name="future_wait_until_bridgehead"></a>
483  <span class="phrase"><a name="future_wait_until"></a></span>
484  <a class="link" href="future.html#future_wait_until">Templated
485          member function <code class="computeroutput">wait_until</code>()</a>
486</h5>
487<p>
488        </p>
489<pre class="programlisting"><span class="keyword">template</span><span class="special">&lt;</span> <span class="keyword">typename</span> <span class="identifier">Clock</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">Duration</span> <span class="special">&gt;</span>
490<span class="identifier">future_status</span> <span class="identifier">wait_until</span><span class="special">(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">chrono</span><span class="special">::</span><span class="identifier">time_point</span><span class="special">&lt;</span> <span class="identifier">Clock</span><span class="special">,</span> <span class="identifier">Duration</span> <span class="special">&gt;</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">timeout_time</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
491</pre>
492<div class="variablelist">
493<p class="title"><b></b></p>
494<dl class="variablelist">
495<dt><span class="term">Effects:</span></dt>
496<dd><p>
497                Waits until <a class="link" href="promise.html#promise_set_value"><code class="computeroutput">promise::set_value()</code></a> or <a class="link" href="promise.html#promise_set_exception"><code class="computeroutput">promise::set_exception()</code></a> is
498                called, or <code class="computeroutput"><span class="identifier">timeout_time</span></code>
499                has passed.
500              </p></dd>
501<dt><span class="term">Result:</span></dt>
502<dd><p>
503                A <code class="computeroutput"><span class="identifier">future_status</span></code> is
504                returned indicating the reason for returning.
505              </p></dd>
506<dt><span class="term">Throws:</span></dt>
507<dd><p>
508                <code class="computeroutput"><span class="identifier">future_error</span></code> with
509                error condition <code class="computeroutput"><span class="identifier">future_errc</span><span class="special">::</span><span class="identifier">no_state</span></code>
510                or timeout-related exceptions.
511              </p></dd>
512</dl>
513</div>
514<p>
515          </p>
516<h5>
517<a name="class_shared_future_bridgehead"></a>
518  <span class="phrase"><a name="class_shared_future"></a></span>
519  <a class="link" href="future.html#class_shared_future">Template
520          <code class="computeroutput">shared_future&lt;&gt;</code></a>
521</h5>
522<p>
523        </p>
524<p>
525          A <a class="link" href="future.html#class_shared_future"><code class="computeroutput">shared_future&lt;&gt;</code></a> contains a <a class="link" href="future.html#shared_state">shared
526          state</a> which might be shared with other <a class="link" href="future.html#class_shared_future"><code class="computeroutput">shared_future&lt;&gt;</code></a> instances.
527        </p>
528<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">fiber</span><span class="special">/</span><span class="identifier">future</span><span class="special">/</span><span class="identifier">future</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
529
530<span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span>
531<span class="keyword">namespace</span> <span class="identifier">fibers</span> <span class="special">{</span>
532
533<span class="keyword">template</span><span class="special">&lt;</span> <span class="keyword">typename</span> <span class="identifier">R</span> <span class="special">&gt;</span>
534<span class="keyword">class</span> <span class="identifier">shared_future</span> <span class="special">{</span>
535<span class="keyword">public</span><span class="special">:</span>
536    <span class="identifier">shared_future</span><span class="special">()</span> <span class="keyword">noexcept</span><span class="special">;</span>
537
538    <span class="special">~</span><span class="identifier">shared_future</span><span class="special">();</span>
539
540    <span class="identifier">shared_future</span><span class="special">(</span> <span class="identifier">shared_future</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">other</span><span class="special">);</span>
541
542    <span class="identifier">shared_future</span><span class="special">(</span> <span class="identifier">future</span><span class="special">&lt;</span> <span class="identifier">R</span> <span class="special">&gt;</span> <span class="special">&amp;&amp;</span> <span class="identifier">other</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span>
543
544    <span class="identifier">shared_future</span><span class="special">(</span> <span class="identifier">shared_future</span> <span class="special">&amp;&amp;</span> <span class="identifier">other</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span>
545
546    <span class="identifier">shared_future</span> <span class="special">&amp;</span> <span class="keyword">operator</span><span class="special">=(</span> <span class="identifier">shared_future</span> <span class="special">&amp;&amp;</span> <span class="identifier">other</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span>
547
548    <span class="identifier">shared_future</span> <span class="special">&amp;</span> <span class="keyword">operator</span><span class="special">=(</span> <span class="identifier">future</span><span class="special">&lt;</span> <span class="identifier">R</span> <span class="special">&gt;</span> <span class="special">&amp;&amp;</span> <span class="identifier">other</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span>
549
550    <span class="identifier">shared_future</span> <span class="special">&amp;</span> <span class="keyword">operator</span><span class="special">=(</span> <span class="identifier">shared_future</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">other</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span>
551
552    <span class="keyword">bool</span> <span class="identifier">valid</span><span class="special">()</span> <span class="keyword">const</span> <span class="keyword">noexcept</span><span class="special">;</span>
553
554    <span class="identifier">R</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">get</span><span class="special">();</span> <span class="comment">// member only of generic shared_future template</span>
555    <span class="identifier">R</span> <span class="special">&amp;</span> <span class="identifier">get</span><span class="special">();</span>      <span class="comment">// member only of shared_future&lt; R &amp; &gt; template specialization</span>
556    <span class="keyword">void</span> <span class="identifier">get</span><span class="special">();</span>     <span class="comment">// member only of shared_future&lt; void &gt; template specialization</span>
557
558    <span class="identifier">std</span><span class="special">::</span><span class="identifier">exception_ptr</span> <span class="identifier">get_exception_ptr</span><span class="special">();</span>
559
560    <span class="keyword">void</span> <span class="identifier">wait</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
561
562    <span class="keyword">template</span><span class="special">&lt;</span> <span class="keyword">class</span> <span class="identifier">Rep</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Period</span> <span class="special">&gt;</span>
563    <span class="identifier">future_status</span> <span class="identifier">wait_for</span><span class="special">(</span>
564        <span class="identifier">std</span><span class="special">::</span><span class="identifier">chrono</span><span class="special">::</span><span class="identifier">duration</span><span class="special">&lt;</span> <span class="identifier">Rep</span><span class="special">,</span> <span class="identifier">Period</span> <span class="special">&gt;</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">timeout_duration</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
565
566    <span class="keyword">template</span><span class="special">&lt;</span> <span class="keyword">typename</span> <span class="identifier">Clock</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">Duration</span> <span class="special">&gt;</span>
567    <span class="identifier">future_status</span> <span class="identifier">wait_until</span><span class="special">(</span>
568        <span class="identifier">std</span><span class="special">::</span><span class="identifier">chrono</span><span class="special">::</span><span class="identifier">time_point</span><span class="special">&lt;</span> <span class="identifier">Clock</span><span class="special">,</span> <span class="identifier">Duration</span> <span class="special">&gt;</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">timeout_time</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
569<span class="special">};</span>
570
571<span class="special">}}</span>
572</pre>
573<h6>
574<a name="fiber.synchronization.futures.future.h7"></a>
575          <span class="phrase"><a name="fiber.synchronization.futures.future.default_constructor0"></a></span><a class="link" href="future.html#fiber.synchronization.futures.future.default_constructor0">Default
576          constructor</a>
577        </h6>
578<pre class="programlisting"><span class="identifier">shared_future</span><span class="special">();</span>
579</pre>
580<div class="variablelist">
581<p class="title"><b></b></p>
582<dl class="variablelist">
583<dt><span class="term">Effects:</span></dt>
584<dd><p>
585                Creates a shared_future with no <a class="link" href="future.html#shared_state">shared
586                state</a>. After construction <code class="computeroutput"><span class="keyword">false</span>
587                <span class="special">==</span> <span class="identifier">valid</span><span class="special">()</span></code>.
588              </p></dd>
589<dt><span class="term">Throws:</span></dt>
590<dd><p>
591                Nothing.
592              </p></dd>
593</dl>
594</div>
595<h6>
596<a name="fiber.synchronization.futures.future.h8"></a>
597          <span class="phrase"><a name="fiber.synchronization.futures.future.move_constructor0"></a></span><a class="link" href="future.html#fiber.synchronization.futures.future.move_constructor0">Move constructor</a>
598        </h6>
599<pre class="programlisting"><span class="identifier">shared_future</span><span class="special">(</span> <span class="identifier">future</span><span class="special">&lt;</span> <span class="identifier">R</span> <span class="special">&gt;</span> <span class="special">&amp;&amp;</span> <span class="identifier">other</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span>
600<span class="identifier">shared_future</span><span class="special">(</span> <span class="identifier">shared_future</span> <span class="special">&amp;&amp;</span> <span class="identifier">other</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span>
601</pre>
602<div class="variablelist">
603<p class="title"><b></b></p>
604<dl class="variablelist">
605<dt><span class="term">Effects:</span></dt>
606<dd><p>
607                Constructs a shared_future with the <a class="link" href="future.html#shared_state">shared
608                state</a> of other. After construction <code class="computeroutput"><span class="keyword">false</span>
609                <span class="special">==</span> <span class="identifier">other</span><span class="special">.</span><span class="identifier">valid</span><span class="special">()</span></code>.
610              </p></dd>
611<dt><span class="term">Throws:</span></dt>
612<dd><p>
613                Nothing.
614              </p></dd>
615</dl>
616</div>
617<h6>
618<a name="fiber.synchronization.futures.future.h9"></a>
619          <span class="phrase"><a name="fiber.synchronization.futures.future.copy_constructor"></a></span><a class="link" href="future.html#fiber.synchronization.futures.future.copy_constructor">Copy constructor</a>
620        </h6>
621<pre class="programlisting"><span class="identifier">shared_future</span><span class="special">(</span> <span class="identifier">shared_future</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">other</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span>
622</pre>
623<div class="variablelist">
624<p class="title"><b></b></p>
625<dl class="variablelist">
626<dt><span class="term">Effects:</span></dt>
627<dd><p>
628                Constructs a shared_future with the <a class="link" href="future.html#shared_state">shared
629                state</a> of other. After construction <code class="computeroutput"><span class="identifier">other</span><span class="special">.</span><span class="identifier">valid</span><span class="special">()</span></code> is unchanged.
630              </p></dd>
631<dt><span class="term">Throws:</span></dt>
632<dd><p>
633                Nothing.
634              </p></dd>
635</dl>
636</div>
637<h6>
638<a name="fiber.synchronization.futures.future.h10"></a>
639          <span class="phrase"><a name="fiber.synchronization.futures.future.destructor0"></a></span><a class="link" href="future.html#fiber.synchronization.futures.future.destructor0">Destructor</a>
640        </h6>
641<pre class="programlisting"><span class="special">~</span><span class="identifier">shared_future</span><span class="special">();</span>
642</pre>
643<div class="variablelist">
644<p class="title"><b></b></p>
645<dl class="variablelist">
646<dt><span class="term">Effects:</span></dt>
647<dd><p>
648                Destroys the shared_future; ownership is abandoned if not shared.
649              </p></dd>
650<dt><span class="term">Note:</span></dt>
651<dd><p>
652                <code class="computeroutput">~shared_future()</code> does <span class="emphasis"><em>not</em></span> block the calling fiber.
653              </p></dd>
654</dl>
655</div>
656<p>
657          </p>
658<h5>
659<a name="shared_future_operator_assign_bridgehead"></a>
660  <span class="phrase"><a name="shared_future_operator_assign"></a></span>
661  <a class="link" href="future.html#shared_future_operator_assign">Member
662          function <code class="computeroutput">operator=</code>()</a>
663</h5>
664<p>
665        </p>
666<pre class="programlisting"><span class="identifier">shared_future</span> <span class="special">&amp;</span> <span class="keyword">operator</span><span class="special">=(</span> <span class="identifier">future</span><span class="special">&lt;</span> <span class="identifier">R</span> <span class="special">&gt;</span> <span class="special">&amp;&amp;</span> <span class="identifier">other</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span>
667<span class="identifier">shared_future</span> <span class="special">&amp;</span> <span class="keyword">operator</span><span class="special">=(</span> <span class="identifier">shared_future</span> <span class="special">&amp;&amp;</span> <span class="identifier">other</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span>
668<span class="identifier">shared_future</span> <span class="special">&amp;</span> <span class="keyword">operator</span><span class="special">=(</span> <span class="identifier">shared_future</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">other</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span>
669</pre>
670<div class="variablelist">
671<p class="title"><b></b></p>
672<dl class="variablelist">
673<dt><span class="term">Effects:</span></dt>
674<dd><p>
675                Moves or copies the <a class="link" href="future.html#shared_state">shared state</a>
676                of other to <code class="computeroutput"><span class="keyword">this</span></code>. After
677                the assignment, the state of <code class="computeroutput"><span class="identifier">other</span><span class="special">.</span><span class="identifier">valid</span><span class="special">()</span></code> depends on which overload was invoked:
678                unchanged for the overload accepting <code class="computeroutput"><span class="identifier">shared_future</span>
679                <span class="keyword">const</span><span class="special">&amp;</span></code>,
680                otherwise <code class="computeroutput"><span class="keyword">false</span></code>.
681              </p></dd>
682<dt><span class="term">Throws:</span></dt>
683<dd><p>
684                Nothing.
685              </p></dd>
686</dl>
687</div>
688<p>
689          </p>
690<h5>
691<a name="shared_future_valid_bridgehead"></a>
692  <span class="phrase"><a name="shared_future_valid"></a></span>
693  <a class="link" href="future.html#shared_future_valid">Member
694          function <code class="computeroutput">valid</code>()</a>
695</h5>
696<p>
697        </p>
698<pre class="programlisting"><span class="keyword">bool</span> <span class="identifier">valid</span><span class="special">()</span> <span class="keyword">const</span> <span class="keyword">noexcept</span><span class="special">;</span>
699</pre>
700<div class="variablelist">
701<p class="title"><b></b></p>
702<dl class="variablelist">
703<dt><span class="term">Effects:</span></dt>
704<dd><p>
705                Returns <code class="computeroutput"><span class="keyword">true</span></code> if shared_future
706                contains a <a class="link" href="future.html#shared_state">shared state</a>.
707              </p></dd>
708<dt><span class="term">Throws:</span></dt>
709<dd><p>
710                Nothing.
711              </p></dd>
712</dl>
713</div>
714<p>
715          </p>
716<h5>
717<a name="shared_future_get_bridgehead"></a>
718  <span class="phrase"><a name="shared_future_get"></a></span>
719  <a class="link" href="future.html#shared_future_get">Member function
720          <code class="computeroutput">get</code>()</a>
721</h5>
722<p>
723        </p>
724<pre class="programlisting"><span class="identifier">R</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">get</span><span class="special">();</span> <span class="comment">// member only of generic shared_future template</span>
725<span class="identifier">R</span> <span class="special">&amp;</span> <span class="identifier">get</span><span class="special">();</span>      <span class="comment">// member only of shared_future&lt; R &amp; &gt; template specialization</span>
726<span class="keyword">void</span> <span class="identifier">get</span><span class="special">();</span>     <span class="comment">// member only of shared_future&lt; void &gt; template specialization</span>
727</pre>
728<div class="variablelist">
729<p class="title"><b></b></p>
730<dl class="variablelist">
731<dt><span class="term">Precondition:</span></dt>
732<dd><p>
733                <code class="computeroutput"><span class="keyword">true</span> <span class="special">==</span>
734                <span class="identifier">valid</span><span class="special">()</span></code>
735              </p></dd>
736<dt><span class="term">Returns:</span></dt>
737<dd><p>
738                Waits until <a class="link" href="promise.html#promise_set_value"><code class="computeroutput">promise::set_value()</code></a> or <a class="link" href="promise.html#promise_set_exception"><code class="computeroutput">promise::set_exception()</code></a> is
739                called. If <a class="link" href="promise.html#promise_set_value"><code class="computeroutput">promise::set_value()</code></a> is called, returns
740                the value. If <a class="link" href="promise.html#promise_set_exception"><code class="computeroutput">promise::set_exception()</code></a> is called,
741                throws the indicated exception.
742              </p></dd>
743<dt><span class="term">Postcondition:</span></dt>
744<dd><p>
745                <code class="computeroutput"><span class="keyword">false</span> <span class="special">==</span>
746                <span class="identifier">valid</span><span class="special">()</span></code>
747              </p></dd>
748<dt><span class="term">Throws:</span></dt>
749<dd><p>
750                <code class="computeroutput"><span class="identifier">future_error</span></code> with
751                error condition <code class="computeroutput"><span class="identifier">future_errc</span><span class="special">::</span><span class="identifier">no_state</span></code>,
752                <code class="computeroutput"><span class="identifier">future_errc</span><span class="special">::</span><span class="identifier">broken_promise</span></code>. Any exception passed
753                to <code class="computeroutput"><span class="identifier">promise</span><span class="special">::</span><span class="identifier">set_exception</span><span class="special">()</span></code>.
754              </p></dd>
755</dl>
756</div>
757<p>
758          </p>
759<h5>
760<a name="shared_future_get_exception_ptr_bridgehead"></a>
761  <span class="phrase"><a name="shared_future_get_exception_ptr"></a></span>
762  <a class="link" href="future.html#shared_future_get_exception_ptr">Member
763          function <code class="computeroutput">get_exception_ptr</code>()</a>
764</h5>
765<p>
766        </p>
767<pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">exception_ptr</span> <span class="identifier">get_exception_ptr</span><span class="special">();</span>
768</pre>
769<div class="variablelist">
770<p class="title"><b></b></p>
771<dl class="variablelist">
772<dt><span class="term">Precondition:</span></dt>
773<dd><p>
774                <code class="computeroutput"><span class="keyword">true</span> <span class="special">==</span>
775                <span class="identifier">valid</span><span class="special">()</span></code>
776              </p></dd>
777<dt><span class="term">Returns:</span></dt>
778<dd><p>
779                Waits until <a class="link" href="promise.html#promise_set_value"><code class="computeroutput">promise::set_value()</code></a> or <a class="link" href="promise.html#promise_set_exception"><code class="computeroutput">promise::set_exception()</code></a> is
780                called. If <code class="computeroutput"><span class="identifier">set_value</span><span class="special">()</span></code> is called, returns a default-constructed
781                <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">exception_ptr</span></code>. If <code class="computeroutput"><span class="identifier">set_exception</span><span class="special">()</span></code>
782                is called, returns the passed <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">exception_ptr</span></code>.
783              </p></dd>
784<dt><span class="term">Throws:</span></dt>
785<dd><p>
786                <code class="computeroutput"><span class="identifier">future_error</span></code> with
787                error condition <code class="computeroutput"><span class="identifier">future_errc</span><span class="special">::</span><span class="identifier">no_state</span></code>.
788              </p></dd>
789<dt><span class="term">Note:</span></dt>
790<dd><p>
791                <code class="computeroutput"><span class="identifier">get_exception_ptr</span><span class="special">()</span></code> does <span class="emphasis"><em>not</em></span> invalidate
792                the <code class="computeroutput">shared_future</code>. After calling <code class="computeroutput"><span class="identifier">get_exception_ptr</span><span class="special">()</span></code>, you may still call <a class="link" href="future.html#shared_future_get"><code class="computeroutput">shared_future::get()</code></a>.
793              </p></dd>
794</dl>
795</div>
796<p>
797          </p>
798<h5>
799<a name="shared_future_wait_bridgehead"></a>
800  <span class="phrase"><a name="shared_future_wait"></a></span>
801  <a class="link" href="future.html#shared_future_wait">Member
802          function <code class="computeroutput">wait</code>()</a>
803</h5>
804<p>
805        </p>
806<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">wait</span><span class="special">();</span>
807</pre>
808<div class="variablelist">
809<p class="title"><b></b></p>
810<dl class="variablelist">
811<dt><span class="term">Effects:</span></dt>
812<dd><p>
813                Waits until <a class="link" href="promise.html#promise_set_value"><code class="computeroutput">promise::set_value()</code></a> or <a class="link" href="promise.html#promise_set_exception"><code class="computeroutput">promise::set_exception()</code></a> is
814                called.
815              </p></dd>
816<dt><span class="term">Throws:</span></dt>
817<dd><p>
818                <code class="computeroutput"><span class="identifier">future_error</span></code> with
819                error condition <code class="computeroutput"><span class="identifier">future_errc</span><span class="special">::</span><span class="identifier">no_state</span></code>.
820              </p></dd>
821</dl>
822</div>
823<p>
824          </p>
825<h5>
826<a name="shared_future_wait_for_bridgehead"></a>
827  <span class="phrase"><a name="shared_future_wait_for"></a></span>
828  <a class="link" href="future.html#shared_future_wait_for">Templated
829          member function <code class="computeroutput">wait_for</code>()</a>
830</h5>
831<p>
832        </p>
833<pre class="programlisting"><span class="keyword">template</span><span class="special">&lt;</span> <span class="keyword">class</span> <span class="identifier">Rep</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Period</span> <span class="special">&gt;</span>
834<span class="identifier">future_status</span> <span class="identifier">wait_for</span><span class="special">(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">chrono</span><span class="special">::</span><span class="identifier">duration</span><span class="special">&lt;</span> <span class="identifier">Rep</span><span class="special">,</span> <span class="identifier">Period</span> <span class="special">&gt;</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">timeout_duration</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
835</pre>
836<div class="variablelist">
837<p class="title"><b></b></p>
838<dl class="variablelist">
839<dt><span class="term">Effects:</span></dt>
840<dd><p>
841                Waits until <a class="link" href="promise.html#promise_set_value"><code class="computeroutput">promise::set_value()</code></a> or <a class="link" href="promise.html#promise_set_exception"><code class="computeroutput">promise::set_exception()</code></a> is
842                called, or <code class="computeroutput"><span class="identifier">timeout_duration</span></code>
843                has passed.
844              </p></dd>
845<dt><span class="term">Result:</span></dt>
846<dd><p>
847                A <code class="computeroutput"><span class="identifier">future_status</span></code> is
848                returned indicating the reason for returning.
849              </p></dd>
850<dt><span class="term">Throws:</span></dt>
851<dd><p>
852                <code class="computeroutput"><span class="identifier">future_error</span></code> with
853                error condition <code class="computeroutput"><span class="identifier">future_errc</span><span class="special">::</span><span class="identifier">no_state</span></code>
854                or timeout-related exceptions.
855              </p></dd>
856</dl>
857</div>
858<p>
859          </p>
860<h5>
861<a name="shared_future_wait_until_bridgehead"></a>
862  <span class="phrase"><a name="shared_future_wait_until"></a></span>
863  <a class="link" href="future.html#shared_future_wait_until">Templated
864          member function <code class="computeroutput">wait_until</code>()</a>
865</h5>
866<p>
867        </p>
868<pre class="programlisting"><span class="keyword">template</span><span class="special">&lt;</span> <span class="keyword">typename</span> <span class="identifier">Clock</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">Duration</span> <span class="special">&gt;</span>
869<span class="identifier">future_status</span> <span class="identifier">wait_until</span><span class="special">(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">chrono</span><span class="special">::</span><span class="identifier">time_point</span><span class="special">&lt;</span> <span class="identifier">Clock</span><span class="special">,</span> <span class="identifier">Duration</span> <span class="special">&gt;</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">timeout_time</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
870</pre>
871<div class="variablelist">
872<p class="title"><b></b></p>
873<dl class="variablelist">
874<dt><span class="term">Effects:</span></dt>
875<dd><p>
876                Waits until <a class="link" href="promise.html#promise_set_value"><code class="computeroutput">promise::set_value()</code></a> or <a class="link" href="promise.html#promise_set_exception"><code class="computeroutput">promise::set_exception()</code></a> is
877                called, or <code class="computeroutput"><span class="identifier">timeout_time</span></code>
878                has passed.
879              </p></dd>
880<dt><span class="term">Result:</span></dt>
881<dd><p>
882                A <code class="computeroutput"><span class="identifier">future_status</span></code> is
883                returned indicating the reason for returning.
884              </p></dd>
885<dt><span class="term">Throws:</span></dt>
886<dd><p>
887                <code class="computeroutput"><span class="identifier">future_error</span></code> with
888                error condition <code class="computeroutput"><span class="identifier">future_errc</span><span class="special">::</span><span class="identifier">no_state</span></code>
889                or timeout-related exceptions.
890              </p></dd>
891</dl>
892</div>
893<p>
894          </p>
895<h5>
896<a name="fibers_async_bridgehead"></a>
897  <span class="phrase"><a name="fibers_async"></a></span>
898  <a class="link" href="future.html#fibers_async">Non-member function <code class="computeroutput">fibers::async()</code></a>
899</h5>
900<p>
901        </p>
902<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">fiber</span><span class="special">/</span><span class="identifier">future</span><span class="special">/</span><span class="identifier">async</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
903
904<span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span>
905<span class="keyword">namespace</span> <span class="identifier">fibers</span> <span class="special">{</span>
906
907<span class="keyword">template</span><span class="special">&lt;</span> <span class="keyword">class</span> <span class="identifier">Function</span><span class="special">,</span> <span class="keyword">class</span> <span class="special">...</span> <span class="identifier">Args</span> <span class="special">&gt;</span>
908<span class="identifier">future</span><span class="special">&lt;</span>
909    <span class="identifier">std</span><span class="special">::</span><span class="identifier">result_of_t</span><span class="special">&lt;</span>
910        <span class="identifier">std</span><span class="special">::</span><span class="identifier">decay_t</span><span class="special">&lt;</span> <span class="identifier">Function</span> <span class="special">&gt;(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">decay_t</span><span class="special">&lt;</span> <span class="identifier">Args</span> <span class="special">&gt;</span> <span class="special">...</span> <span class="special">)</span>
911    <span class="special">&gt;</span>
912<span class="special">&gt;</span>
913<span class="identifier">async</span><span class="special">(</span> <span class="identifier">Function</span> <span class="special">&amp;&amp;</span> <span class="identifier">fn</span><span class="special">,</span> <span class="identifier">Args</span> <span class="special">&amp;&amp;</span> <span class="special">...</span> <span class="identifier">args</span><span class="special">);</span>
914
915<span class="keyword">template</span><span class="special">&lt;</span> <span class="keyword">class</span> <span class="identifier">Function</span><span class="special">,</span> <span class="keyword">class</span> <span class="special">...</span> <span class="identifier">Args</span> <span class="special">&gt;</span>
916<span class="identifier">future</span><span class="special">&lt;</span>
917    <span class="identifier">std</span><span class="special">::</span><span class="identifier">result_of_t</span><span class="special">&lt;</span>
918        <span class="identifier">std</span><span class="special">::</span><span class="identifier">decay_t</span><span class="special">&lt;</span> <span class="identifier">Function</span> <span class="special">&gt;(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">decay_t</span><span class="special">&lt;</span> <span class="identifier">Args</span> <span class="special">&gt;</span> <span class="special">...</span> <span class="special">)</span>
919    <span class="special">&gt;</span>
920<span class="special">&gt;</span>
921<span class="identifier">async</span><span class="special">(</span> <a class="link" href="../../fiber_mgmt.html#class_launch"><code class="computeroutput"><span class="identifier">launch</span></code></a> <span class="identifier">policy</span><span class="special">,</span> <span class="identifier">Function</span> <span class="special">&amp;&amp;</span> <span class="identifier">fn</span><span class="special">,</span> <span class="identifier">Args</span> <span class="special">&amp;&amp;</span> <span class="special">...</span> <span class="identifier">args</span><span class="special">);</span>
922
923<span class="keyword">template</span><span class="special">&lt;</span> <span class="keyword">typename</span> <a class="link" href="../../stack.html#stack_allocator_concept"><code class="computeroutput"><span class="identifier">StackAllocator</span></code></a><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Function</span><span class="special">,</span> <span class="keyword">class</span> <span class="special">...</span> <span class="identifier">Args</span> <span class="special">&gt;</span>
924<span class="identifier">future</span><span class="special">&lt;</span>
925    <span class="identifier">std</span><span class="special">::</span><span class="identifier">result_of_t</span><span class="special">&lt;</span>
926        <span class="identifier">std</span><span class="special">::</span><span class="identifier">decay_t</span><span class="special">&lt;</span> <span class="identifier">Function</span> <span class="special">&gt;(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">decay_t</span><span class="special">&lt;</span> <span class="identifier">Args</span> <span class="special">&gt;</span> <span class="special">...</span> <span class="special">)</span>
927    <span class="special">&gt;</span>
928<span class="special">&gt;</span>
929<span class="identifier">async</span><span class="special">(</span> <a class="link" href="../../fiber_mgmt.html#class_launch"><code class="computeroutput"><span class="identifier">launch</span></code></a> <span class="identifier">policy</span><span class="special">,</span> <a href="http://en.cppreference.com/w/cpp/memory/allocator_arg_t" target="_top"><code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">allocator_arg_t</span></code></a><span class="special">,</span> <a class="link" href="../../stack.html#stack_allocator_concept"><code class="computeroutput"><span class="identifier">StackAllocator</span></code></a> <span class="identifier">salloc</span><span class="special">,</span>
930       <span class="identifier">Function</span> <span class="special">&amp;&amp;</span> <span class="identifier">fn</span><span class="special">,</span> <span class="identifier">Args</span> <span class="special">&amp;&amp;</span> <span class="special">...</span> <span class="identifier">args</span><span class="special">);</span>
931
932<span class="keyword">template</span><span class="special">&lt;</span> <span class="keyword">typename</span> <a class="link" href="../../stack.html#stack_allocator_concept"><code class="computeroutput"><span class="identifier">StackAllocator</span></code></a><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">Allocator</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Function</span><span class="special">,</span> <span class="keyword">class</span> <span class="special">...</span> <span class="identifier">Args</span> <span class="special">&gt;</span>
933<span class="identifier">future</span><span class="special">&lt;</span>
934    <span class="identifier">std</span><span class="special">::</span><span class="identifier">result_of_t</span><span class="special">&lt;</span>
935        <span class="identifier">std</span><span class="special">::</span><span class="identifier">decay_t</span><span class="special">&lt;</span> <span class="identifier">Function</span> <span class="special">&gt;(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">decay_t</span><span class="special">&lt;</span> <span class="identifier">Args</span> <span class="special">&gt;</span> <span class="special">...</span> <span class="special">)</span>
936    <span class="special">&gt;</span>
937<span class="special">&gt;</span>
938<span class="identifier">async</span><span class="special">(</span> <a class="link" href="../../fiber_mgmt.html#class_launch"><code class="computeroutput"><span class="identifier">launch</span></code></a> <span class="identifier">policy</span><span class="special">,</span> <a href="http://en.cppreference.com/w/cpp/memory/allocator_arg_t" target="_top"><code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">allocator_arg_t</span></code></a><span class="special">,</span> <a class="link" href="../../stack.html#stack_allocator_concept"><code class="computeroutput"><span class="identifier">StackAllocator</span></code></a> <span class="identifier">salloc</span><span class="special">,</span>
939       <span class="identifier">Allocator</span> <span class="identifier">alloc</span><span class="special">,</span> <span class="identifier">Function</span> <span class="special">&amp;&amp;</span> <span class="identifier">fn</span><span class="special">,</span> <span class="identifier">Args</span> <span class="special">&amp;&amp;</span> <span class="special">...</span> <span class="identifier">args</span><span class="special">);</span>
940
941<span class="special">}}</span>
942</pre>
943<div class="variablelist">
944<p class="title"><b></b></p>
945<dl class="variablelist">
946<dt><span class="term">Effects:</span></dt>
947<dd><p>
948                Executes <code class="computeroutput"><span class="identifier">fn</span></code> in a
949                <a class="link" href="../../fiber_mgmt/fiber.html#class_fiber"><code class="computeroutput">fiber</code></a> and returns an associated <a class="link" href="future.html#class_future"><code class="computeroutput">future&lt;&gt;</code></a>.
950              </p></dd>
951<dt><span class="term">Result:</span></dt>
952<dd>
953<p>
954</p>
955<pre class="programlisting"><span class="identifier">future</span><span class="special">&lt;</span>
956    <span class="identifier">std</span><span class="special">::</span><span class="identifier">result_of_t</span><span class="special">&lt;</span>
957        <span class="identifier">std</span><span class="special">::</span><span class="identifier">decay_t</span><span class="special">&lt;</span> <span class="identifier">Function</span> <span class="special">&gt;(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">decay_t</span><span class="special">&lt;</span> <span class="identifier">Args</span> <span class="special">&gt;</span> <span class="special">...</span> <span class="special">)</span>
958    <span class="special">&gt;</span>
959<span class="special">&gt;</span></pre>
960<p>
961                representing the <a class="link" href="future.html#shared_state">shared state</a>
962                associated with the asynchronous execution of <code class="computeroutput"><span class="identifier">fn</span></code>.
963              </p>
964</dd>
965<dt><span class="term">Throws:</span></dt>
966<dd><p>
967                <code class="computeroutput"><span class="identifier">fiber_error</span></code> or <code class="computeroutput"><span class="identifier">future_error</span></code> if an error occurs.
968              </p></dd>
969<dt><span class="term">Notes:</span></dt>
970<dd><p>
971                The overloads accepting <a href="http://en.cppreference.com/w/cpp/memory/allocator_arg_t" target="_top"><code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">allocator_arg_t</span></code></a> use the
972                passed <a class="link" href="../../stack.html#stack_allocator_concept"><code class="computeroutput"><span class="identifier">StackAllocator</span></code></a>
973                when constructing the launched <code class="computeroutput"><span class="identifier">fiber</span></code>.
974                The overloads accepting <a class="link" href="../../fiber_mgmt.html#class_launch"><code class="computeroutput">launch</code></a> use the passed <code class="computeroutput"><span class="identifier">launch</span></code> when constructing the launched
975                <code class="computeroutput"><span class="identifier">fiber</span></code>. The default
976                <code class="computeroutput"><span class="identifier">launch</span></code> is <code class="computeroutput"><span class="identifier">post</span></code>, as for the <code class="computeroutput"><span class="identifier">fiber</span></code> constructor.
977              </p></dd>
978</dl>
979</div>
980<div class="note"><table border="0" summary="Note">
981<tr>
982<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../../doc/src/images/note.png"></td>
983<th align="left">Note</th>
984</tr>
985<tr><td align="left" valign="top"><p>
986            Deferred futures are not supported.
987          </p></td></tr>
988</table></div>
989</div>
990<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
991<td align="left"></td>
992<td align="right"><div class="copyright-footer">Copyright © 2013 Oliver Kowalke<p>
993        Distributed under the Boost Software License, Version 1.0. (See accompanying
994        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>)
995      </p>
996</div></td>
997</tr></table>
998<hr>
999<div class="spirit-nav">
1000<a accesskey="p" href="../futures.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../futures.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="promise.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
1001</div>
1002</body>
1003</html>
1004