33 Execution control library [exec]

33.13 Coroutine utilities [exec.coro.util]

33.13.3 execution​::​affine_on [exec.affine.on]

affine_on adapts a sender into one that completes on the specified scheduler.
If the algorithm determines that the adapted sender already completes on the correct scheduler it can avoid any scheduling operation.
The name affine_on denotes a pipeable sender adaptor object.
For subexpressions sch and sndr, if decltype((sch)) does not satisfy scheduler, or decltype((sndr)) does not satisfy sender, affine_on(sndr, sch) is ill-formed.
Otherwise, the expression affine_on(sndr, sch) is expression-equivalent to: transform_sender(get-domain-early(sndr), make-sender(affine_on, sch, sndr)) except that sndr is evaluated only once.
The exposition-only class template impls-for is specialized for affine_on_t as follows:
namespace std::execution { template<> struct impls-for<affine_on_t> : default-impls { static constexpr auto get-attrs = [](const auto& data, const auto& child) noexcept -> decltype(auto) { return JOIN-ENV(SCHED-ATTRS(data), FWD-ENV(get_env(child))); }; }; }
Let out_sndr be a subexpression denoting a sender returned from affine_on(sndr, sch) or one equal to such, and let OutSndr be the type decltype((out_sndr)).
Let out_rcvr be a subexpression denoting a receiver that has an environment of type Env such that sender_in<OutSndr, Env> is true.
Let op be an lvalue referring to the operation state that results from connecting out_sndr to out_rcvr.
Calling start(op) will start sndr on the current execution agent and execute completion operations on out_rcvr on an execution agent of the execution resource associated with sch.
If the current execution resource is the same as the execution resource associated with sch, the completion operation on out_rcvr may be called before start(op) completes.
If scheduling onto sch fails, an error completion on out_rcvr shall be executed on an unspecified execution agent.