33 Execution control library [exec]

33.5 Queries [exec.queries]

33.5.11 execution​::​get_completion_scheduler [exec.get.compl.sched]

The name get_completion_scheduler denotes a query object template.
Let completion-fn be a completion function ([exec.async.ops]); let completion-fn-tag be the associated completion tag of completion-fn; let args and envs be packs of subexpressions; and let sndr be a subexpression such that sender<decltype((sndr))> is true and get_completion_scheduler<completion-fn-tag>(get_env(sndr), envs...) is well-formed and denotes a scheduler sch.
get_completion_scheduler<completion-fn-tag> obtains the completion scheduler associated with a completion tag from a sender's attributes.
For subexpression sch1 and pack envs, let sch2 be TRY-QUERY(sch1, get_completion_scheduler<set_value_t>, envs...) and let RECURSE-QUERY(sch1, envs...) be expression-equivalent to sch1 if sch2 is ill-formed or if sch1 and sch2 have the same type and compare equal; otherwise, RECURSE-QUERY(sch2, envs...).
For a subexpression q and pack envs, the expression get_completion_scheduler<completion-fn-tag>(q, envs...) is ill-formed if completion-fn-tag is not one of set_value_t, set_error_t, or set_stopped_t.
Otherwise, the expression is expression-equivalent to:
  • MANDATE-NOTHROW(RECURSE-QUERY( TRY-QUERY(q, get_completion_scheduler<completion-fn-tag>, envs...), envs...)) if that expression is well-formed, except that envs... is evaluated only once.
  • Otherwise, auto(q) if the type of q satisfies scheduler and envs is not an empty pack, except that envs... is evaluated.
  • Otherwise, get_completion_scheduler<completion-fn-tag>(q, envs...) is ill-formed.
Mandates: If get_completion_scheduler<completion-fn-tag>(q, envs...) is well-formed, its type satisfies scheduler.
For a type Tag, subexpression sndr, and pack envs, let CS be completion_signatures_of_t<decay_t<decltype((sndr))>, decltype((envs))...>.
If both get_completion_scheduler<Tag>(get_env(
sndr), envs...)
and CS are well-formed and CS().count-of(Tag()) == 0 is true, the program is ill-formed.
If an asynchronous operation created by connecting sndr with a receiver rcvr causes the evaluation of completion-fn(rcvr, args...), the behavior is undefined unless the evaluation happens on an execution agent that belongs to sch's associated execution resource.
The expression forwarding_query(get_completion_scheduler<completion-fn-tag>) is a core constant expression and has value true.