33 Execution control library [exec]

33.5 Queries [exec.queries]


33.5.1 Query utilities [exec.queries.expos]

33.5.2 forwarding_query [exec.fwd.env]

33.5.3 get_allocator [exec.get.allocator]

33.5.4 get_stop_token [exec.get.stop.token]

33.5.5 execution​::​get_env [exec.get.env]

33.5.6 execution​::​get_domain [exec.get.domain]

33.5.7 execution​::​get_scheduler [exec.get.scheduler]

33.5.8 execution​::​get_start_scheduler [exec.get.start.scheduler]

33.5.9 execution​::​get_delegation_scheduler [exec.get.delegation.scheduler]

33.5.10 execution​::​get_forward_progress_guarantee [exec.get.fwd.progress]

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

33.5.12 execution​::​get_completion_domain [exec.get.compl.domain]

33.5.13 execution​::​get_await_completion_adaptor [exec.get.await.adapt]


33.5.1 Query utilities [exec.queries.expos]

Subclause [exec.queries] makes use of the following exposition-only entities.
For subexpressions q and tag and pack args, let TRY-QUERY(q, tag, args...) be expression-equivalent to AS-CONST(q).query(tag, args...) if that expression is well-formed, and AS-CONST(q).query(tag) otherwise except that args... is evaluated.
For subexpressions q and tag and pack args, let HIDE-SCHED(q) be an object o such that o.query(​tag, args...) is ill-formed when the decayed type of tag is get_scheduler_t or get_domain_t, and q.query(tag, args...) otherwise.

33.5.2 forwarding_query [exec.fwd.env]

forwarding_query asks a query object whether it should be forwarded through queryable adaptors.
The name forwarding_query denotes a query object.
For some query object q of type Q, forwarding_query(q) is expression-equivalent to:
  • MANDATE-NOTHROW(q.query(forwarding_query)) if that expression is well-formed.
    Mandates: The expression above has type bool and is a core constant expression if q is a core constant expression.
  • Otherwise, true if derived_from<Q, forwarding_query_t> is true.
  • Otherwise, false.

33.5.3 get_allocator [exec.get.allocator]

get_allocator asks a queryable object for its associated allocator.
The name get_allocator denotes a query object.
For a subexpression env, get_allocator(env) is expression-equivalent to MANDATE-NOTHROW(AS-CONST(env).query(get_allocator)).
Mandates: If the expression above is well-formed, its type satisfies simple-allocator ([allocator.requirements.general]).
forwarding_query(get_allocator) is a core constant expression and has value true.

33.5.4 get_stop_token [exec.get.stop.token]

get_stop_token asks a queryable object for an associated stop token.
The name get_stop_token denotes a query object.
For a subexpression env, get_stop_token(env) is expression-equivalent to:
  • MANDATE-NOTHROW(AS-CONST(env).query(get_stop_token)) if that expression is well-formed.
    Mandates: The type of the expression above satisfies stoppable_token.
  • Otherwise, never_stop_token{}.
forwarding_query(get_stop_token) is a core constant expression and has value true.

33.5.5 execution​::​get_env [exec.get.env]

execution​::​get_env is a customization point object.
For a subexpression o, execution​::​get_env(o) is expression-equivalent to:
The value of get_env(o) shall be valid while o is valid.
[Note 1: 
When passed a sender object, get_env returns the sender's associated attributes.
When passed a receiver, get_env returns the receiver's associated execution environment.
— end note]

33.5.6 execution​::​get_domain [exec.get.domain]

get_domain asks a queryable object for its associated execution domain tag.
The name get_domain denotes a query object.
For a subexpression env, get_domain(env) is expression-equivalent to MANDATE-NOTHROW(D()), where D is the type of the first of the following expressions that is well-formed:
  • auto(AS-CONST(env).query(get_domain)).
  • get_completion_domain<set_value_t>(get_scheduler(env), HIDE-SCHED(env)).
  • default_domain(), except that env is evaluated.
forwarding_query(execution​::​get_domain) is a core constant expression and has value true.

33.5.7 execution​::​get_scheduler [exec.get.scheduler]

get_scheduler asks a queryable object for its associated scheduler.
The name get_scheduler denotes a query object.
For a subexpression env, get_scheduler(env) is expression-equivalent to get_completion_scheduler<set_value_t>( MANDATE-NOTHROW(AS-CONST(env).query(get_scheduler)), HIDE-SCHED(env)).
Mandates: If the expression above is well-formed, its type satisfies scheduler.
forwarding_query(execution​::​get_scheduler) is a core constant expression and has value true.

33.5.8 execution​::​get_start_scheduler [exec.get.start.scheduler]

get_start_scheduler asks a queryable object for the scheduler an operation will be or was started on.
The name get_start_scheduler denotes a query object.
For a subexpression env, get_start_scheduler(​env) is expression-equivalent to MANDATE-NOTHROW(AS-CONST(env).query(get_start_scheduler)).
Mandates: If the expression above is well-formed, its type satisfies scheduler.
forwarding_query(execution​::​get_start_scheduler) is a core constant expression and has value true.
Given subexpressions sndr and rcvr such that sender-to<decltype((sndr)), decltype((rcvr))> is true and the expression get_start_scheduler(get_env(rcvr)) is well-formed, an operation state that is the result of calling connect(sndr, rcvr) shall, if it is started, be started on an execution agent associated with the scheduler get_start_scheduler(get_env(rcvr)).

33.5.9 execution​::​get_delegation_scheduler [exec.get.delegation.scheduler]

get_delegation_scheduler asks a queryable object for a scheduler that can be used to delegate work to for the purpose of forward progress delegation ([intro.progress]).
The name get_delegation_scheduler denotes a query object.
For a subexpression env, get_delegation_scheduler(env) is expression-equivalent to MANDATE-NOTHROW(AS-CONST(env).query(get_delegation_scheduler)).
Mandates: If the expression above is well-formed, its type satisfies scheduler.
forwarding_query(execution​::​get_delegation_scheduler) is a core constant expression and has value true.

33.5.10 execution​::​get_forward_progress_guarantee [exec.get.fwd.progress]

namespace std::execution { enum class forward_progress_guarantee { concurrent, parallel, weakly_parallel }; }
get_forward_progress_guarantee asks a scheduler about the forward progress guarantee of execution agents created by that scheduler's associated execution resource ([intro.progress]).
The name get_forward_progress_guarantee denotes a query object.
For a subexpression sch, let Sch be decltype((sch)).
If Sch does not satisfy scheduler, get_forward_progress_guarantee is ill-formed.
Otherwise, get_forward_progress_guarantee(sch) is expression-equivalent to: MANDATE-NOTHROW(AS-CONST(sch).query(get_forward_progress_guarantee))
Mandates: The type of the expression above is forward_progress_guarantee.
If get_forward_progress_guarantee(sch) for some scheduler sch returns forward_progress_guarantee​::​concurrent, all execution agents created by that scheduler's associated execution resource shall provide the concurrent forward progress guarantee.
If it returns forward_progress_guarantee​::​parallel, all such execution agents shall provide at least the parallel forward progress guarantee.

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, get_completion_scheduler<completion-fn-tag>(q, envs...) 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.

33.5.12 execution​::​get_completion_domain [exec.get.compl.domain]

get_completion_domain<completion-tag> obtains the completion domain associated with a completion tag from a sender's attributes.
The name get_completion_domain denotes a query object template.
For a subexpression attrs and pack envs, the expression get_completion_domain<completion-tag>(attrs, envs...) is ill-formed if completion-tag is not one of void, set_value_t, set_error_t, or set_stopped_t.
Otherwise, it is expression-equivalent to MANDATE-NOTHROW(D()), where D is:
  • The type of TRY-QUERY(attrs, get_completion_domain<completion-tag>, envs...) if that expression is well-formed.
  • Otherwise, the type of get_completion_domain<set_value_t>(attrs, envs...) if completion-tag is void.
  • Otherwise, the type of TRY-QUERY(get_completion_scheduler<completion-tag>(attrs, envs...), get_completion_domain<set_value_t>, envs...) if that expression is well-formed.
  • Otherwise, default_domain if scheduler<decltype((attrs))> is true and envs is not an empty pack.
  • Otherwise, get_completion_domain<completion-tag>(attrs, envs...) is ill-formed.
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_domain<Tag>(get_env(sndr), envs...) and CS are well-formed and CS().count-of(Tag()) == 0 is true, the program is ill-formed.
Let completion-fn be a completion function ([exec.async.ops]); let completion-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_domain<completion-tag>(get_env(sndr), envs...) is well-formed and denotes a domain tag D.
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 of an execution resource whose associated execution domain tag is D.
The expression forwarding_query(get_completion_domain<completion-tag>) is a core constant expression and has value true.

33.5.13 execution​::​get_await_completion_adaptor [exec.get.await.adapt]

get_await_completion_adaptor asks a queryable object for its associated awaitable completion adaptor.
The name get_await_completion_adaptor denotes a query object.
For a subexpression env, get_await_completion_adaptor(env) is expression-equivalent to MANDATE-NOTHROW(AS-CONST(env).query(get_await_completion_adaptor))
forwarding_query(execution​::​get_await_completion_adaptor) is a core constant expression and has value true.