1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>yield_context</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="write_at/overload8.html" title="write_at (8 of 8 overloads)"> 10<link rel="next" href="is_error_code_enum_lt__addrinfo_errors__gt_.html" title="boost::system::is_error_code_enum< boost::asio::error::addrinfo_errors >"> 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="write_at/overload8.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="is_error_code_enum_lt__addrinfo_errors__gt_.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.yield_context"></a><a class="link" href="yield_context.html" title="yield_context">yield_context</a> 28</h3></div></div></div> 29<p> 30 <a class="indexterm" name="boost_asio.indexterm.yield_context"></a> 31Context object that represents 32 the currently executing coroutine. 33 </p> 34<pre class="programlisting">typedef basic_yield_context< unspecified > yield_context; 35</pre> 36<h5> 37<a name="boost_asio.reference.yield_context.h0"></a> 38 <span class="phrase"><a name="boost_asio.reference.yield_context.types"></a></span><a class="link" href="yield_context.html#boost_asio.reference.yield_context.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> 58<tr> 59<td> 60 <p> 61 <a class="link" href="basic_yield_context/callee_type.html" title="basic_yield_context::callee_type"><span class="bold"><strong>callee_type</strong></span></a> 62 </p> 63 </td> 64<td> 65 <p> 66 The coroutine callee type, used by the implementation. 67 </p> 68 </td> 69</tr> 70<tr> 71<td> 72 <p> 73 <a class="link" href="basic_yield_context/caller_type.html" title="basic_yield_context::caller_type"><span class="bold"><strong>caller_type</strong></span></a> 74 </p> 75 </td> 76<td> 77 <p> 78 The coroutine caller type, used by the implementation. 79 </p> 80 </td> 81</tr> 82</tbody> 83</table></div> 84<h5> 85<a name="boost_asio.reference.yield_context.h1"></a> 86 <span class="phrase"><a name="boost_asio.reference.yield_context.member_functions"></a></span><a class="link" href="yield_context.html#boost_asio.reference.yield_context.member_functions">Member 87 Functions</a> 88 </h5> 89<div class="informaltable"><table class="table"> 90<colgroup> 91<col> 92<col> 93</colgroup> 94<thead><tr> 95<th> 96 <p> 97 Name 98 </p> 99 </th> 100<th> 101 <p> 102 Description 103 </p> 104 </th> 105</tr></thead> 106<tbody> 107<tr> 108<td> 109 <p> 110 <a class="link" href="basic_yield_context/basic_yield_context.html" title="basic_yield_context::basic_yield_context"><span class="bold"><strong>basic_yield_context</strong></span></a> <span class="silver">[constructor]</span> 111 </p> 112 </td> 113<td> 114 <p> 115 Construct a yield context to represent the specified coroutine. 116 <br> <span class="silver"> —</span><br> Construct a yield context from another yield context 117 type. 118 </p> 119 </td> 120</tr> 121<tr> 122<td> 123 <p> 124 <a class="link" href="basic_yield_context/operator_lb__rb_.html" title="basic_yield_context::operator[]"><span class="bold"><strong>operator[]</strong></span></a> 125 </p> 126 </td> 127<td> 128 <p> 129 Return a yield context that sets the specified error_code. 130 </p> 131 </td> 132</tr> 133</tbody> 134</table></div> 135<p> 136 The <a class="link" href="basic_yield_context.html" title="basic_yield_context"><code class="computeroutput">basic_yield_context</code></a> 137 class is used to represent the currently executing stackful coroutine. A 138 <a class="link" href="basic_yield_context.html" title="basic_yield_context"><code class="computeroutput">basic_yield_context</code></a> 139 may be passed as a handler to an asynchronous operation. For example: 140 </p> 141<pre class="programlisting">template <typename Handler> 142void my_coroutine(basic_yield_context<Handler> yield) 143{ 144 ... 145 std::size_t n = my_socket.async_read_some(buffer, yield); 146 ... 147} 148</pre> 149<p> 150 The initiating function (async_read_some in the above example) suspends the 151 current coroutine. The coroutine is resumed when the asynchronous operation 152 completes, and the result of the operation is returned. 153 </p> 154<h5> 155<a name="boost_asio.reference.yield_context.h2"></a> 156 <span class="phrase"><a name="boost_asio.reference.yield_context.requirements"></a></span><a class="link" href="yield_context.html#boost_asio.reference.yield_context.requirements">Requirements</a> 157 </h5> 158<p> 159 <span class="emphasis"><em>Header: </em></span><code class="literal">boost/asio/spawn.hpp</code> 160 </p> 161<p> 162 <span class="emphasis"><em>Convenience header: </em></span>None 163 </p> 164</div> 165<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 166<td align="left"></td> 167<td align="right"><div class="copyright-footer">Copyright © 2003-2020 Christopher M. 168 Kohlhoff<p> 169 Distributed under the Boost Software License, Version 1.0. (See accompanying 170 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>) 171 </p> 172</div></td> 173</tr></table> 174<hr> 175<div class="spirit-nav"> 176<a accesskey="p" href="write_at/overload8.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="is_error_code_enum_lt__addrinfo_errors__gt_.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a> 177</div> 178</body> 179</html> 180