Scheduler.html 10.2 KB
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Scheduler concept</title>
<link rel="stylesheet" href="../../boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="../../index.html" title="Asio">
<link rel="up" href="../reference.html" title="Reference">
<link rel="prev" href="ResolveHandler.html" title="Resolve handler requirements">
<link rel="next" href="Sender.html" title="Sender concepts">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="asio C++ library" width="250" height="60" src="../../asio.png"></td></tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="ResolveHandler.html"><img src="../../prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../home.png" alt="Home"></a><a accesskey="n" href="Sender.html"><img src="../../next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="asio.reference.Scheduler"></a><a class="link" href="Scheduler.html" title="Scheduler concept">Scheduler concept</a>
</h3></div></div></div>
<pre class="programlisting">template&lt;class S&gt;
  concept scheduler =
    copy_constructible&lt;remove_cvref_t&lt;S&gt;&gt; &amp;&amp;
    equality_comparable&lt;remove_cvref_t&lt;S&gt;&gt; &amp;&amp;
    requires(E&amp;&amp; e) {
      execution::schedule((E&amp;&amp;)e);
    };
</pre>
<p>
        None of a scheduler's copy constructor, destructor, equality comparison,
        or <code class="computeroutput">swap</code> operation shall exit via an exception.
      </p>
<p>
        None of these operations, nor a scheduler type's <code class="computeroutput">schedule</code> function,
        or associated query functions shall introduce data races as a result of concurrent
        invocations of those functions from different threads.
      </p>
<p>
        For any two (possibly const) values <code class="computeroutput">x1</code> and <code class="computeroutput">x2</code> of
        some scheduler type <code class="computeroutput">X</code>, <code class="computeroutput">x1 == x2</code> shall return <code class="computeroutput">true</code>
        only if <code class="computeroutput">asio::query(x1, p) == asio::query(x2, p)</code> for every property
        <code class="computeroutput">p</code> where both <code class="computeroutput">asio::query(x1, p)</code> and <code class="computeroutput">asio::query(x2,
        p)</code> are well-formed and result in a non-void type that is <code class="computeroutput">EqualityComparable</code>
        (C++Std [equalitycomparable]). [<span class="emphasis"><em>Note:</em></span> The above requirements
        imply that <code class="computeroutput">x1 == x2</code> returns <code class="computeroutput">true</code> if <code class="computeroutput">x1</code>
        and <code class="computeroutput">x2</code> can be interchanged with identical effects. A scheduler
        may conceptually contain additional properties which are not exposed by a
        named property type that can be observed via <code class="computeroutput">asio::query</code>; in
        this case, it is up to the concrete scheduler implementation to decide if
        these properties affect equality. Returning <code class="computeroutput">false</code> does not necessarily
        imply that the effects are not identical. —<span class="emphasis"><em>end note</em></span>]
      </p>
<p>
        A scheduler type's destructor shall not block pending completion of any receivers
        submitted to the sender objects returned from <code class="computeroutput">schedule</code>. [<span class="emphasis"><em>Note:</em></span>
        The ability to wait for completion of submitted function objects may be provided
        by the execution context that produced the scheduler. —<span class="emphasis"><em>end note</em></span>]
      </p>
<p>
        In addition to the above requirements, type <code class="computeroutput">S</code> models <code class="computeroutput">scheduler</code>
        only if it satisfies the requirements in the Table below.
      </p>
<p>
        In the Table below,
      </p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem">
            <code class="computeroutput">s</code> denotes a (possibly const) scheduler object of type <code class="computeroutput">S</code>,
          </li>
<li class="listitem">
            <code class="computeroutput">N</code> denotes a type that models <code class="computeroutput">sender</code>, and
          </li>
<li class="listitem">
            <code class="computeroutput">n</code> denotes a sender object of type <code class="computeroutput">N</code>
          </li>
</ul></div>
<div class="table">
<a name="asio.reference.Scheduler.t0"></a><p class="title"><b>Table 25. Scheduler requirements</b></p>
<div class="table-contents"><table class="table" summary="Scheduler requirements">
<colgroup>
<col>
<col>
<col>
</colgroup>
<thead><tr>
<th>
                <p>
                  expression
                </p>
              </th>
<th>
                <p>
                  return type
                </p>
              </th>
<th>
                <p>
                  operation semantics
                </p>
              </th>
</tr></thead>
<tbody><tr>
<td>
                <p>
                  <code class="computeroutput">execution::schedule(s)</code>
                </p>
              </td>
<td>
                <p>
                  <code class="computeroutput">N</code>
                </p>
              </td>
<td>
                <p>
                  Evaluates <code class="computeroutput">execution::schedule(s)</code> on the calling thread
                  to create <code class="computeroutput">N</code>.
                </p>
              </td>
</tr></tbody>
</table></div>
</div>
<br class="table-break"><p>
        <code class="computeroutput">execution::start(o)</code>, where <code class="computeroutput">o</code> is the result of a
        call to <code class="computeroutput">execution::connect(N, r)</code> for some receiver object <code class="computeroutput">r</code>,
        is required to eagerly submit <code class="computeroutput">r</code> for execution on an execution
        agent that <code class="computeroutput">s</code> creates for it. Let <code class="computeroutput">rc</code> be <code class="computeroutput">r</code>
        or an object created by copy or move construction from <code class="computeroutput">r</code>. The
        semantic constraints on the <code class="computeroutput">sender</code> <code class="computeroutput">N</code> returned from
        a scheduler <code class="computeroutput">s</code>'s <code class="computeroutput">schedule</code> function are as follows:
      </p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem">
            If <code class="computeroutput">rc</code>'s <code class="computeroutput">set_error</code> function is called in response
            to a submission error, scheduling error, or other internal error, let
            <code class="computeroutput">E</code> be an expression that refers to that error if <code class="computeroutput">set_error(rc,
            E)</code> is well-formed; otherwise, let <code class="computeroutput">E</code> be an <code class="computeroutput">exception_ptr</code>
            that refers to that error. [Note: <code class="computeroutput">E</code> could be the result
            of calling <code class="computeroutput">current_exception</code> or <code class="computeroutput">make_exception_ptr</code>.]
            The scheduler calls <code class="computeroutput">set_error(rc, E)</code> on an unspecified weakly-parallel
            execution agent ([Note: An invocation of <code class="computeroutput">set_error</code> on a
            receiver is required to be <code class="computeroutput">noexcept</code>]), and
          </li>
<li class="listitem">
            If <code class="computeroutput">rc</code>'s <code class="computeroutput">set_error</code> function is called in response
            to an exception that propagates out of the invocation of <code class="computeroutput">set_value</code>
            on <code class="computeroutput">rc</code>, let <code class="computeroutput">E</code> be <code class="computeroutput">make_exception_ptr(receiver_invocation_error{})</code>
            invoked from within a catch clause that has caught the exception. The
            executor calls <code class="computeroutput">set_error(rc, E)</code> on an unspecified weakly-parallel
            execution agent, and
          </li>
<li class="listitem">
            A call to <code class="computeroutput">set_done(rc)</code> is made on an unspecified weakly-parallel
            execution agent ([Note: An invocation of a receiver's <code class="computeroutput">set_done</code>
            function is required to be <code class="computeroutput">noexcept</code>]).
          </li>
</ul></div>
<p>
        [<span class="emphasis"><em>Note:</em></span> The senders returned from a scheduler's <code class="computeroutput">schedule</code>
        function have wide discretion when deciding which of the three receiver functions
        to call upon submission. —<span class="emphasis"><em>end note</em></span>]
      </p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright © 2003-2020 Christopher M.
      Kohlhoff<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        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>)
      </p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="ResolveHandler.html"><img src="../../prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../home.png" alt="Home"></a><a accesskey="n" href="Sender.html"><img src="../../next.png" alt="Next"></a>
</div>
</body>
</html>