1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>Scheduler concept</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="ResolveHandler.html" title="Resolve handler requirements"> 10<link rel="next" href="Sender.html" title="Sender concepts"> 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="ResolveHandler.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="Sender.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.Scheduler"></a><a class="link" href="Scheduler.html" title="Scheduler concept">Scheduler concept</a> 28</h3></div></div></div> 29<pre class="programlisting">template<class S> 30 concept scheduler = 31 copy_constructible<remove_cvref_t<S>> && 32 equality_comparable<remove_cvref_t<S>> && 33 requires(E&& e) { 34 execution::schedule((E&&)e); 35 }; 36</pre> 37<p> 38 None of a scheduler's copy constructor, destructor, equality comparison, 39 or <code class="computeroutput">swap</code> operation shall exit via an exception. 40 </p> 41<p> 42 None of these operations, nor a scheduler type's <code class="computeroutput">schedule</code> function, 43 or associated query functions shall introduce data races as a result of concurrent 44 invocations of those functions from different threads. 45 </p> 46<p> 47 For any two (possibly const) values <code class="computeroutput">x1</code> and <code class="computeroutput">x2</code> of 48 some scheduler type <code class="computeroutput">X</code>, <code class="computeroutput">x1 == x2</code> shall return <code class="computeroutput">true</code> 49 only if <code class="computeroutput">boost::asio::query(x1, p) == boost::asio::query(x2, p)</code> 50 for every property <code class="computeroutput">p</code> where both <code class="computeroutput">boost::asio::query(x1, 51 p)</code> and <code class="computeroutput">boost::asio::query(x2, p)</code> are well-formed and 52 result in a non-void type that is <code class="computeroutput">EqualityComparable</code> (C++Std 53 [equalitycomparable]). [<span class="emphasis"><em>Note:</em></span> The above requirements 54 imply that <code class="computeroutput">x1 == x2</code> returns <code class="computeroutput">true</code> if <code class="computeroutput">x1</code> 55 and <code class="computeroutput">x2</code> can be interchanged with identical effects. A scheduler 56 may conceptually contain additional properties which are not exposed by a 57 named property type that can be observed via <code class="computeroutput">boost::asio::query</code>; 58 in this case, it is up to the concrete scheduler implementation to decide 59 if these properties affect equality. Returning <code class="computeroutput">false</code> does not 60 necessarily imply that the effects are not identical. —<span class="emphasis"><em>end note</em></span>] 61 </p> 62<p> 63 A scheduler type's destructor shall not block pending completion of any receivers 64 submitted to the sender objects returned from <code class="computeroutput">schedule</code>. [<span class="emphasis"><em>Note:</em></span> 65 The ability to wait for completion of submitted function objects may be provided 66 by the execution context that produced the scheduler. —<span class="emphasis"><em>end note</em></span>] 67 </p> 68<p> 69 In addition to the above requirements, type <code class="computeroutput">S</code> models <code class="computeroutput">scheduler</code> 70 only if it satisfies the requirements in the Table below. 71 </p> 72<p> 73 In the Table below, 74 </p> 75<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> 76<li class="listitem"> 77 <code class="computeroutput">s</code> denotes a (possibly const) scheduler object of type <code class="computeroutput">S</code>, 78 </li> 79<li class="listitem"> 80 <code class="computeroutput">N</code> denotes a type that models <code class="computeroutput">sender</code>, and 81 </li> 82<li class="listitem"> 83 <code class="computeroutput">n</code> denotes a sender object of type <code class="computeroutput">N</code> 84 </li> 85</ul></div> 86<div class="table"> 87<a name="boost_asio.reference.Scheduler.t0"></a><p class="title"><b>Table 25. Scheduler requirements</b></p> 88<div class="table-contents"><table class="table" summary="Scheduler requirements"> 89<colgroup> 90<col> 91<col> 92<col> 93</colgroup> 94<thead><tr> 95<th> 96 <p> 97 expression 98 </p> 99 </th> 100<th> 101 <p> 102 return type 103 </p> 104 </th> 105<th> 106 <p> 107 operation semantics 108 </p> 109 </th> 110</tr></thead> 111<tbody><tr> 112<td> 113 <p> 114 <code class="computeroutput">execution::schedule(s)</code> 115 </p> 116 </td> 117<td> 118 <p> 119 <code class="computeroutput">N</code> 120 </p> 121 </td> 122<td> 123 <p> 124 Evaluates <code class="computeroutput">execution::schedule(s)</code> on the calling thread 125 to create <code class="computeroutput">N</code>. 126 </p> 127 </td> 128</tr></tbody> 129</table></div> 130</div> 131<br class="table-break"><p> 132 <code class="computeroutput">execution::start(o)</code>, where <code class="computeroutput">o</code> is the result of a 133 call to <code class="computeroutput">execution::connect(N, r)</code> for some receiver object <code class="computeroutput">r</code>, 134 is required to eagerly submit <code class="computeroutput">r</code> for execution on an execution 135 agent that <code class="computeroutput">s</code> creates for it. Let <code class="computeroutput">rc</code> be <code class="computeroutput">r</code> 136 or an object created by copy or move construction from <code class="computeroutput">r</code>. The 137 semantic constraints on the <code class="computeroutput">sender</code> <code class="computeroutput">N</code> returned from 138 a scheduler <code class="computeroutput">s</code>'s <code class="computeroutput">schedule</code> function are as follows: 139 </p> 140<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> 141<li class="listitem"> 142 If <code class="computeroutput">rc</code>'s <code class="computeroutput">set_error</code> function is called in response 143 to a submission error, scheduling error, or other internal error, let 144 <code class="computeroutput">E</code> be an expression that refers to that error if <code class="computeroutput">set_error(rc, 145 E)</code> is well-formed; otherwise, let <code class="computeroutput">E</code> be an <code class="computeroutput">exception_ptr</code> 146 that refers to that error. [Note: <code class="computeroutput">E</code> could be the result 147 of calling <code class="computeroutput">current_exception</code> or <code class="computeroutput">make_exception_ptr</code>.] 148 The scheduler calls <code class="computeroutput">set_error(rc, E)</code> on an unspecified weakly-parallel 149 execution agent ([Note: An invocation of <code class="computeroutput">set_error</code> on a 150 receiver is required to be <code class="computeroutput">noexcept</code>]), and 151 </li> 152<li class="listitem"> 153 If <code class="computeroutput">rc</code>'s <code class="computeroutput">set_error</code> function is called in response 154 to an exception that propagates out of the invocation of <code class="computeroutput">set_value</code> 155 on <code class="computeroutput">rc</code>, let <code class="computeroutput">E</code> be <code class="computeroutput">make_exception_ptr(receiver_invocation_error{})</code> 156 invoked from within a catch clause that has caught the exception. The 157 executor calls <code class="computeroutput">set_error(rc, E)</code> on an unspecified weakly-parallel 158 execution agent, and 159 </li> 160<li class="listitem"> 161 A call to <code class="computeroutput">set_done(rc)</code> is made on an unspecified weakly-parallel 162 execution agent ([Note: An invocation of a receiver's <code class="computeroutput">set_done</code> 163 function is required to be <code class="computeroutput">noexcept</code>]). 164 </li> 165</ul></div> 166<p> 167 [<span class="emphasis"><em>Note:</em></span> The senders returned from a scheduler's <code class="computeroutput">schedule</code> 168 function have wide discretion when deciding which of the three receiver functions 169 to call upon submission. —<span class="emphasis"><em>end note</em></span>] 170 </p> 171</div> 172<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 173<td align="left"></td> 174<td align="right"><div class="copyright-footer">Copyright © 2003-2020 Christopher M. 175 Kohlhoff<p> 176 Distributed under the Boost Software License, Version 1.0. (See accompanying 177 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>) 178 </p> 179</div></td> 180</tr></table> 181<hr> 182<div class="spirit-nav"> 183<a accesskey="p" href="ResolveHandler.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="Sender.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a> 184</div> 185</body> 186</html> 187