Files
cppdraft_translate/cppdraft/exec/affine/on.md
2025-10-25 03:02:53 +03:00

3.1 KiB
Raw Blame History

[exec.affine.on]

33 Execution control library [exec]

33.13 Coroutine utilities [exec.coro.util]

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

1

#

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.

2

#

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.

3

#

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.

4

#

The exposition-only class template impls-for ([exec.snd.expos]) 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))); }; };}

5

#

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 withsch.

If the current execution resource is the same as the execution resource associated with sch, the completion operation onout_rcvr may be called before start(op) completes.

If scheduling onto sch fails, an error completion onout_rcvr shall be executed on an unspecified execution agent.