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:Receiver Receiver concepts] 9 10A receiver represents the continuation of an asynchronous operation. An 11asynchronous operation may complete with a (possibly empty) set of values, an 12error, or it may be cancelled. A receiver has three principal operations 13corresponding to the three ways an asynchronous operation may complete: 14`set_value`, `set_error`, and `set_done`. These are collectively known as a 15receiver’s ['completion-signal operations]. 16 17 18 template<class T, class E = exception_ptr> 19 concept receiver = 20 move_constructible<remove_cvref_t<T>> && 21 constructible_from<remove_cvref_t<T>, T> && 22 requires(remove_cvref_t<T>&& t, E&& e) { 23 { execution::set_done(std::move(t)) } noexcept; 24 { execution::set_error(std::move(t), (E&&) e) } noexcept; 25 }; 26 27 template<class T, class... An> 28 concept receiver_of = 29 receiver<T> && 30 requires(remove_cvref_t<T>&& t, An&&... an) { 31 execution::set_value(std::move(t), (An&&) an...); 32 }; 33 34The receiver’s completion-signal operations have semantic requirements that are 35collectively known as the ['receiver contract], described below: 36 37* None of a receiver’s completion-signal operations shall be invoked before 38 `execution::start` has been called on the operation state object that was 39 returned by `execution::connect` to connect that receiver to a sender. 40 41* Once `execution::start` has been called on the operation state object, 42 exactly one of the receiver’s completion-signal operations shall complete 43 non-exceptionally before the receiver is destroyed. 44 45* If `execution::set_value` exits with an exception, it is still valid to call 46 `execution::set_error` or `execution::set_done` on the receiver. 47 48Once one of a receiver’s completion-signal operations has completed 49non-exceptionally, the receiver contract has been satisfied. 50 51[endsect] 52