]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | <html> |
2 | <head> | |
3 | <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> | |
4 | <title>when_any, a dubious alternative</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="../when_any.html" title="when_any"> | |
9 | <link rel="prev" href="when_any__heterogeneous_types.html" title="when_any, heterogeneous types"> | |
10 | <link rel="next" href="../when_all_functionality.html" title="when_all functionality"> | |
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="when_any__heterogeneous_types.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../when_any.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="../when_all_functionality.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.when_any.when_any.when_any__a_dubious_alternative"></a><a class="link" href="when_any__a_dubious_alternative.html" title="when_any, a dubious alternative">when_any, | |
28 | a dubious alternative</a> | |
29 | </h4></div></div></div> | |
30 | <p> | |
31 | Certain topics in C++ can arouse strong passions, and exceptions are no | |
32 | exception. We cannot resist mentioning — for purely informational purposes | |
33 | — that when you need only the <span class="emphasis"><em>first</em></span> result from some | |
34 | number of concurrently-running fibers, it would be possible to pass a | |
35 | <code class="literal">shared_ptr<<a class="link" href="../../synchronization/futures/promise.html#class_promise"><code class="computeroutput">promise<></code></a>></code> to the | |
36 | participating fibers, then cause the initiating fiber to call <a class="link" href="../../synchronization/futures/future.html#future_get"><code class="computeroutput">future::get()</code></a> on | |
37 | its <a class="link" href="../../synchronization/futures/future.html#class_future"><code class="computeroutput">future<></code></a>. The first fiber to call <a class="link" href="../../synchronization/futures/promise.html#promise_set_value"><code class="computeroutput">promise::set_value()</code></a> on | |
38 | that shared <code class="computeroutput"><span class="identifier">promise</span></code> will | |
39 | succeed; subsequent <code class="computeroutput"><span class="identifier">set_value</span><span class="special">()</span></code> calls on the same <code class="computeroutput"><span class="identifier">promise</span></code> | |
40 | instance will throw <code class="computeroutput"><span class="identifier">future_error</span></code>. | |
41 | </p> | |
42 | <p> | |
43 | Use this information at your own discretion. Beware the dark side. | |
44 | </p> | |
45 | </div> | |
46 | <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> | |
47 | <td align="left"></td> | |
48 | <td align="right"><div class="copyright-footer">Copyright © 2013 Oliver Kowalke<p> | |
49 | Distributed under the Boost Software License, Version 1.0. (See accompanying | |
50 | 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>) | |
51 | </p> | |
52 | </div></td> | |
53 | </tr></table> | |
54 | <hr> | |
55 | <div class="spirit-nav"> | |
56 | <a accesskey="p" href="when_any__heterogeneous_types.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../when_any.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="../when_all_functionality.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a> | |
57 | </div> | |
58 | </body> | |
59 | </html> |