• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1[/
2 / Copyright (c) 2003-2021 Christopher M. Kohlhoff (chris at kohlhoff dot com)
3 /
4 / Distributed under the Boost Software License, Version 1.0. (See accompanying
5 / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 /]
7
8[section:Scheduler Scheduler concept]
9
10    template<class S>
11      concept scheduler =
12        copy_constructible<remove_cvref_t<S>> &&
13        equality_comparable<remove_cvref_t<S>> &&
14        requires(E&& e) {
15          execution::schedule((E&&)e);
16        };
17
18None of a scheduler's copy constructor, destructor, equality comparison, or
19`swap` operation shall exit via an exception.
20
21None of these operations, nor a scheduler type's `schedule` function, or
22associated query functions shall introduce data races as a result of concurrent
23invocations of those functions from different threads.
24
25For any two (possibly const) values `x1` and `x2` of some scheduler type `X`,
26`x1 == x2` shall return `true` only if `boost::asio::query(x1, p) == boost::asio::query(x2,
27p)` for every property `p` where both `boost::asio::query(x1, p)` and `boost::asio::query(x2,
28p)` are well-formed and result in a non-void type that is `EqualityComparable`
29(C++Std [equalitycomparable]). [inline_note The above requirements imply that
30`x1 == x2` returns `true` if `x1` and `x2` can be interchanged with identical
31effects. A scheduler may conceptually contain additional properties which are
32not exposed by a named property type that can be observed via `boost::asio::query`; in
33this case, it is up to the concrete scheduler implementation to decide if these
34properties affect equality. Returning `false` does not necessarily imply that
35the effects are not identical.]
36
37A scheduler type's destructor shall not block pending completion of any
38receivers submitted to the sender objects returned from `schedule`.
39[inline_note The ability to wait for completion of submitted function objects
40may be provided by the execution context that produced the scheduler.]
41
42In addition to the above requirements, type `S` models `scheduler` only if it
43satisfies the requirements in the Table below.
44
45In the Table below,
46
47* `s` denotes a (possibly const) scheduler object of type `S`,
48* `N` denotes a type that models `sender`, and
49* `n` denotes a sender object of type `N`
50
51[table Scheduler requirements
52  [[expression] [return type] [operation semantics]]
53  [
54    [`execution::schedule(s)`]
55    [`N`]
56    [Evaluates `execution::schedule(s)` on the calling thread to create `N`.]
57  ]
58]
59
60`execution::start(o)`, where `o` is the result of a call to
61`execution::connect(N, r)` for some receiver object `r`, is required to eagerly
62submit `r` for execution on an execution agent that `s` creates for it. Let
63`rc` be `r` or an object created by copy or move construction from `r`. The
64semantic constraints on the `sender` `N` returned from a scheduler `s`'s
65`schedule` function are as follows:
66
67* If `rc`'s `set_error` function is called in response to a submission error,
68  scheduling error, or other internal error, let `E` be an expression that
69  refers to that error if `set_error(rc, E)` is well-formed; otherwise, let `E`
70  be an `exception_ptr` that refers to that error. [Note: `E` could be the
71  result of calling `current_exception` or `make_exception_ptr`.]
72  The scheduler calls `set_error(rc, E)` on an unspecified weakly-parallel
73  execution agent ([Note: An invocation of `set_error` on a receiver is
74  required to be `noexcept`]), and
75
76* If `rc`'s `set_error` function is called in response to an exception that
77  propagates out of the invocation of `set_value` on `rc`, let `E` be
78  `make_exception_ptr(receiver_invocation_error{})` invoked from within a catch
79  clause that has caught the exception. The executor calls `set_error(rc, E)`
80  on an unspecified weakly-parallel execution agent, and
81
82* A call to `set_done(rc)` is made on an unspecified weakly-parallel execution
83  agent ([Note: An invocation of a receiver's `set_done` function is required
84  to be `noexcept`]).
85
86[inline_note The senders returned from a scheduler's `schedule` function have
87wide discretion when deciding which of the three receiver functions to call
88upon submission.]
89
90[endsect]
91