• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4<title>Receiver concepts</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="../../boost_asio.html" title="Boost.Asio">
8<link rel="up" href="../reference.html" title="Reference">
9<link rel="prev" href="ReadHandler.html" title="Read handler requirements">
10<link rel="next" href="ResolveHandler.html" title="Resolve handler requirements">
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="ReadHandler.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../boost_asio.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="ResolveHandler.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="boost_asio.reference.Receiver"></a><a class="link" href="Receiver.html" title="Receiver concepts">Receiver concepts</a>
28</h3></div></div></div>
29<p>
30        A receiver represents the continuation of an asynchronous operation. An asynchronous
31        operation may complete with a (possibly empty) set of values, an error, or
32        it may be cancelled. A receiver has three principal operations corresponding
33        to the three ways an asynchronous operation may complete: <code class="computeroutput">set_value</code>,
34        <code class="computeroutput">set_error</code>, and <code class="computeroutput">set_done</code>. These are collectively
35        known as a receiver’s <span class="emphasis"><em>completion-signal operations</em></span>.
36      </p>
37<pre class="programlisting">template&lt;class T, class E = exception_ptr&gt;
38concept receiver =
39  move_constructible&lt;remove_cvref_t&lt;T&gt;&gt; &amp;&amp;
40  constructible_from&lt;remove_cvref_t&lt;T&gt;, T&gt; &amp;&amp;
41  requires(remove_cvref_t&lt;T&gt;&amp;&amp; t, E&amp;&amp; e) {
42    { execution::set_done(std::move(t)) } noexcept;
43    { execution::set_error(std::move(t), (E&amp;&amp;) e) } noexcept;
44  };
45
46template&lt;class T, class... An&gt;
47concept receiver_of =
48  receiver&lt;T&gt; &amp;&amp;
49  requires(remove_cvref_t&lt;T&gt;&amp;&amp; t, An&amp;&amp;... an) {
50    execution::set_value(std::move(t), (An&amp;&amp;) an...);
51  };
52</pre>
53<p>
54        The receiver’s completion-signal operations have semantic requirements
55        that are collectively known as the <span class="emphasis"><em>receiver contract</em></span>,
56        described below:
57      </p>
58<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
59<li class="listitem">
60            None of a receiver’s completion-signal operations shall be invoked
61            before <code class="computeroutput">execution::start</code> has been called on the operation
62            state object that was returned by <code class="computeroutput">execution::connect</code> to
63            connect that receiver to a sender.
64          </li>
65<li class="listitem">
66            Once <code class="computeroutput">execution::start</code> has been called on the operation state
67            object, exactly one of the receiver’s completion-signal operations
68            shall complete non-exceptionally before the receiver is destroyed.
69          </li>
70<li class="listitem">
71            If <code class="computeroutput">execution::set_value</code> exits with an exception, it is still
72            valid to call <code class="computeroutput">execution::set_error</code> or <code class="computeroutput">execution::set_done</code>
73            on the receiver.
74          </li>
75</ul></div>
76<p>
77        Once one of a receiver’s completion-signal operations has completed non-exceptionally,
78        the receiver contract has been satisfied.
79      </p>
80</div>
81<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
82<td align="left"></td>
83<td align="right"><div class="copyright-footer">Copyright © 2003-2020 Christopher M.
84      Kohlhoff<p>
85        Distributed under the Boost Software License, Version 1.0. (See accompanying
86        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>)
87      </p>
88</div></td>
89</tr></table>
90<hr>
91<div class="spirit-nav">
92<a accesskey="p" href="ReadHandler.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../boost_asio.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="ResolveHandler.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
93</div>
94</body>
95</html>
96