Imported Upstream version 1.72.0
[platform/upstream/boost.git] / doc / html / boost_asio / reference / use_awaitable_t.html
1 <html>
2 <head>
3 <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
4 <title>use_awaitable_t</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="use_awaitable.html" title="use_awaitable">
10 <link rel="next" href="use_awaitable_t/as_default_on.html" title="use_awaitable_t::as_default_on">
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="use_awaitable.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="use_awaitable_t/as_default_on.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.use_awaitable_t"></a><a class="link" href="use_awaitable_t.html" title="use_awaitable_t">use_awaitable_t</a>
28 </h3></div></div></div>
29 <p>
30         A completion token that represents the currently executing coroutine.
31       </p>
32 <pre class="programlisting">template&lt;
33     typename <a class="link" href="Executor1.html" title="Executor requirements">Executor</a> = executor&gt;
34 struct use_awaitable_t
35 </pre>
36 <h5>
37 <a name="boost_asio.reference.use_awaitable_t.h0"></a>
38         <span class="phrase"><a name="boost_asio.reference.use_awaitable_t.types"></a></span><a class="link" href="use_awaitable_t.html#boost_asio.reference.use_awaitable_t.types">Types</a>
39       </h5>
40 <div class="informaltable"><table class="table">
41 <colgroup>
42 <col>
43 <col>
44 </colgroup>
45 <thead><tr>
46 <th>
47                 <p>
48                   Name
49                 </p>
50               </th>
51 <th>
52                 <p>
53                   Description
54                 </p>
55               </th>
56 </tr></thead>
57 <tbody><tr>
58 <td>
59                 <p>
60                   <a class="link" href="use_awaitable_t__executor_with_default.html" title="use_awaitable_t::executor_with_default"><span class="bold"><strong>executor_with_default</strong></span></a>
61                 </p>
62               </td>
63 <td>
64                 <p>
65                   Adapts an executor to add the use_awaitable_t completion token
66                   as the default.
67                 </p>
68               </td>
69 </tr></tbody>
70 </table></div>
71 <h5>
72 <a name="boost_asio.reference.use_awaitable_t.h1"></a>
73         <span class="phrase"><a name="boost_asio.reference.use_awaitable_t.member_functions"></a></span><a class="link" href="use_awaitable_t.html#boost_asio.reference.use_awaitable_t.member_functions">Member Functions</a>
74       </h5>
75 <div class="informaltable"><table class="table">
76 <colgroup>
77 <col>
78 <col>
79 </colgroup>
80 <thead><tr>
81 <th>
82                 <p>
83                   Name
84                 </p>
85               </th>
86 <th>
87                 <p>
88                   Description
89                 </p>
90               </th>
91 </tr></thead>
92 <tbody>
93 <tr>
94 <td>
95                 <p>
96                   <a class="link" href="use_awaitable_t/as_default_on.html" title="use_awaitable_t::as_default_on"><span class="bold"><strong>as_default_on</strong></span></a>
97                 </p>
98               </td>
99 <td>
100                 <p>
101                   Function helper to adapt an I/O object to use use_awaitable_t as
102                   its default completion token type.
103                 </p>
104               </td>
105 </tr>
106 <tr>
107 <td>
108                 <p>
109                   <a class="link" href="use_awaitable_t/use_awaitable_t.html" title="use_awaitable_t::use_awaitable_t"><span class="bold"><strong>use_awaitable_t</strong></span></a>
110                 </p>
111               </td>
112 <td>
113                 <p>
114                   Default constructor.
115                 </p>
116               </td>
117 </tr>
118 </tbody>
119 </table></div>
120 <p>
121         The <code class="computeroutput">use_awaitable_t</code> class, with its value <code class="computeroutput">use_awaitable</code>,
122         is used to represent the currently executing coroutine. This completion token
123         may be passed as a handler to an asynchronous operation. For example:
124       </p>
125 <pre class="programlisting">awaitable&lt;void&gt; my_coroutine()
126 {
127   std::size_t n = co_await my_socket.async_read_some(buffer, use_awaitable);
128   ...
129 }
130 </pre>
131 <p>
132         When used with co_await, the initiating function (<code class="computeroutput">async_read_some</code>
133         in the above example) suspends the current coroutine. The coroutine is resumed
134         when the asynchronous operation completes, and the result of the operation
135         is returned.
136       </p>
137 <h5>
138 <a name="boost_asio.reference.use_awaitable_t.h2"></a>
139         <span class="phrase"><a name="boost_asio.reference.use_awaitable_t.requirements"></a></span><a class="link" href="use_awaitable_t.html#boost_asio.reference.use_awaitable_t.requirements">Requirements</a>
140       </h5>
141 <p>
142         <span class="emphasis"><em>Header: </em></span><code class="literal">boost/asio/use_awaitable.hpp</code>
143       </p>
144 <p>
145         <span class="emphasis"><em>Convenience header: </em></span><code class="literal">boost/asio.hpp</code>
146       </p>
147 </div>
148 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
149 <td align="left"></td>
150 <td align="right"><div class="copyright-footer">Copyright &#169; 2003-2019 Christopher M. Kohlhoff<p>
151         Distributed under the Boost Software License, Version 1.0. (See accompanying
152         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>)
153       </p>
154 </div></td>
155 </tr></table>
156 <hr>
157 <div class="spirit-nav">
158 <a accesskey="p" href="use_awaitable.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="use_awaitable_t/as_default_on.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
159 </div>
160 </body>
161 </html>