You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<p>The queries are used to obtain properties associated with an object. Except <code><ahref="‘#forwarding-query’">forwarding_query</a></code>, <code><ahref="‘#get-env’">get_env</a></code>, and <code><ahref="‘#get-completion-signatures’">get_completion_signatures</a></code> the queries work on <ahref="‘#environment’">environments</a>. The <ahref="‘#environment’">environment</a> queries are defined by providing a member <code>query(<em>query_t</em>, <em>a...</em>) const</code> on the <ahref="‘#environment’">environment</a> object. </p><details>
441
+
<p>The queries are used to obtain properties associated with an object.</p>
442
+
<details>
442
443
<summary>
443
444
Example defining a query on an environment</summary>
444
445
<p>This example shows how to define an environment class which provides a <ahref="‘#get-allocator’"><code>get_allocator</code></a> query. The objects stores a <code>std::pmr::memory_resource*</code> and returns a correspondingly initialized <code>std::pmr::polymorphic_allocator<></code>.</p>
<code>forwarding_query(<em>query</em>)</code> is a <code>constexpr</code> query used to determine if the query <code><em>query</em></code> should be forwarded when wrapping an environment. </p><blockquoteclass="doxtable">
458
+
The expression <code>forwarding_query(<em>query</em>)</code> is a <code>constexpr</code> query used to determine if the query <code><em>query</em></code> should be forwarded when wrapping an environment. The expression is required to be a core constant expression if <code><em>query</em></code> is a core constant expression.</p>
459
+
<p>The result of the expression is determined as follows: </p><ol>
460
+
<li>
461
+
The result is the value of the expression <code><em>query</em>.query(forwarding_query)</code> if this expression is valid and <code>noexcept</code>. </li>
462
+
<li>
463
+
The result is <code>true</code> if the type of <code><em>query</em></code> is <code>public</code>ly derived from <code>forwarding_query</code>. </li>
<code>get_env(<em>queryable</em>)</code> is used to get the environment <code><em>env</em></code> associated with <code><em>queryable</em></code>. To provide a non-default environment for a <code><em>queryable</em></code> a <code>get_env</code> member needs to be defined. If <code><em>queryable</em></code> doesn’t provide the <code>get_env</code> query an object of type <code><ahref="‘#empty_env’">empty_env</a></code> is returned. </p><div><details>
493
+
The expresion <code>get_env(<em>queryable</em>)</code> is used to get the environment <code><em>env</em></code> associated with <code><em>queryable</em></code>. To provide a non-default environment for a <code><em>queryable</em></code> a <code>get_env</code> member needs to be defined. If <code><em>queryable</em></code> doesn’t provide the <code>get_env</code> query an object of type <code><ahref="‘#empty_env’">empty_env</a></code> is returned. The value of the expression is </p><ol>
494
+
<li>
495
+
the result of <code>as_const(<em>queryable</em>).get_env()</code> if this expression is valid and <code>noexcept</code>. </li>
496
+
<li>
497
+
<code>empty_env</code> otherwise. </li>
498
+
</ol>
499
+
<div><details>
484
500
<summary>
485
501
Example</summary>
486
502
<p>The example defines an <ahref="‘#environment’">environment</a> class <code>env</code> which stores a pointer to the relevant data and is returned as the <ahref="‘#environment’">environment</a> for the type <code>queryable</code>:</p>
<code>get_allocator(<em>env</em>)</code> returns an <code><em>allocator</em></code> for any memory allocations in the respective context. If <code><em>env</em></code> doesn’t support this query any attempt to access it will result in a compilation error. </p><div><details>
520
+
The expression <code>get_allocator(<em>env</em>)</code> returns an <code><em>allocator</em></code> for any memory allocations in the respective context. If <code><em>env</em></code> doesn’t support this query any attempt to access it will result in a compilation error. The value of the expression <code>get_allocator(<em>env</em>)</code> is the result of <code>as_const(<em>env</em>).query(get_allocator)</code> if </p><ul>
521
+
<li>
522
+
the expression is valid; </li>
523
+
<li>
524
+
the expression is <code>noexcept</code>; </li>
525
+
<li>
526
+
the result of the expression satisfies <code><em>simple-allocator</em></code>. </li>
527
+
</ul>
528
+
<p>Otherwise the expression is ill-formed. </p>
529
+
</details>
530
+
<div><details>
505
531
<summary>
506
532
Example</summary>
507
533
<p>This example shows how to define an environment class which provides a <ahref="‘#get-allocator’"><code>get_allocator</code></a> query. The objects stores a <code>std::pmr::memory_resource*</code> and returns a correspondingly initialized <code>std::pmr::polymorphic_allocator<></code>.</p>
If the expression <code>get_completion_scheduler<tag>(get_env(<em>sender</em>))</code> is well-formed and returns a scheduler it defines the scheduler on which the completion <code><em>tag</em></code> executes. In particular <code>get_completion_scheduler<set_value_t>(schedule(<em>sched</em>))</code> returns <code><em>sched</em></code>. </p>
546
+
The expression <code>get_complet_scheduler<Tag>(<em>env</em>)</code> yields the completion scheduler for the completion signal <code>Tag</code> associated with <code><em>env</em></code>. This query can be used to determine the scheduler a sender <code><em>sender</em></code> completes on for a given completion signal <code>Tag</code> by using <code>get_completion_scheduler<Tag>(get_env(<em>sender</em>))</code>. The value of the expression is equivalent to <code>as_const(<em>env</em>).query(get_completion_scheduler<Tag>)</code> if </p><ol>
547
+
<li>
548
+
<code>Tag</code> is one of the types <code>set_value_t</code>, <code>set_error_t</code>, or <code>set_stopped_t</code>; </li>
549
+
<li>
550
+
this expression is valid; </li>
551
+
<li>
552
+
this expression is <code>noexcept</code>; </li>
553
+
<li>
554
+
the expression’s type satisfies <code>scheduler</code>. </li>
<p>The expression <code>get_completion_signatures(<em>sender</em>, <em>env</em>)</code> returns an object whose type is a specialization of <ahref="‘#completion-signatures’"><code>completion_signatures</code></a> defining the possible completion signatures of <code><em>sender</em></code> when connected to a <ahref="‘#receiver’"><code><em>receiver</em></code></a> whose <a href=‘::environment'>environment <code>get_env(<em>receiver</em>)</code> is <code><em>env</em></code>. A <ahref="‘#sender’"><code>sender</code></a> can define the result of this query either by defining a member function <code>get_completion_signatures</code> or using a type alias <code>completion_signatures</code>. </p><div><details>
561
+
<p>The expression <code>get_completion_signatures(<em>sender</em>, <em>env</em>)</code> returns an object whose type is a specialization of <ahref="‘#completion-signatures’"><code>completion_signatures</code></a> defining the possible completion signatures of <code><em>sender</em></code> when connected to a <ahref="‘#receiver’"><code><em>receiver</em></code></a> whose <a href=‘::environment'>environment <code>get_env(<em>receiver</em>)</code> is <code><em>env</em></code>. A <ahref="‘#sender’"><code>sender</code></a> can define the result of this query either by defining a member function <code>get_completion_signatures</code> or using a type alias <code>completion_signatures</code>.</p>
562
+
<p>To determine the result the <code><em>sender</em></code> is first transformed using <code>transform_sender(<em>domain</em>, <em>sender</em>, <em>env</em>)</code> to get <code><em>new-sender</em></code> with type <code><em>New-Sender-Type</em></code>. With that the result type is </p><ol>
563
+
<li>
564
+
the type of <code><em>new-sender</em>.get_completion_signatures(<em>env</em>)</code> if this expression is valid; </li>
565
+
<li>
566
+
the type <code>remove_cvref_t<<em>New-Sender-Type</em>>::completion_signatures</code> if this type exists; </li>
567
+
<li>
568
+
<code>completion_signatures<set_value_t(<em>T</em>), set_error_t(exception_ptr), set_stopped_t()></code> if <code><em>New-Sender-Type</em></code> is an awaitable type which would yield an object of type <code><em>T</em></code> when it is <code>co_await</code>ed; </li>
569
+
<li>
570
+
invalid otherwise. </li>
571
+
</ol>
572
+
<div><details>
527
573
<summary>
528
574
Example</summary>
529
-
<p>When a <ahref="‘#sender’"><code>sender</code></a> doesn’t need to compute the completion signatures based on an <ahref="‘#environment’">environment</a> it is easiest to use a the type alias:</p>
530
-
<p></p>
531
-
</details>
575
+
<p>When a <ahref="‘#sender’"><code>sender</code></a> doesn’t need to compute the completion signatures based on an <ahref="‘#environment’">environment</a> it is easiest to use a the type alias, e.g.: </p><divclass="fragment"><divclass="line"> {c++}</div>
576
+
<divclass="line">struct sender {</div>
577
+
<divclass="line"> using sender_concept = std::execution::sender_t;</div>
578
+
<divclass="line"> using completion_signatures = std::completion_signatures<</div>
<p>The expression <code>get_delegation_scheduler(<em>env</em>)</code> yields the scheduler associated with <code><em>env</em></code> which is used for forward progress delegation. The value of the expression is equivalent to <code>as_const(<em>env</em>).query(get_delegation_scheduler) -> <em>scheduler</em></code> if </p><ol>
591
+
<li>
592
+
this expression is valid; </li>
593
+
<li>
594
+
this expression is <code>noexcept</code>; </li>
595
+
<li>
596
+
the expression’s type satisfies <code>scheduler</code>. </li>
<p>The expression <code>get_domain(<em>env</em>)</code> yields the domain associated with <code><em>env</em></code>. The value of the expression is equivalent to <code>as_const(<em>env</em>).query(get_domain)</code> if </p><ol>
<p>The expression <code>get_forward_progress_guarantee(<em>scheduler</em>)</code> yields the forward progress guarantee of the <em>scheduler</em>’s execution agent. The value of the expression is equivalent to <code>as_const(<em>env</em>).query(get_scheduler)</code> if </p><ol>
616
+
<li>
617
+
this expression is valid; </li>
618
+
<li>
619
+
this expression is <code>noexcept</code>; </li>
620
+
<li>
621
+
the expression’s type is <code>forward_progress_guarantee</code>. </li>
<p>The expression <code>get_scheduler(<em>env</em>)</code> yields the scheduler associated with <code><em>env</em></code>. The value of the expression is equivalent to <code>as_const(<em>env</em>).query(get_scheduler)</code> if </p><ol>
629
+
<li>
630
+
this expression is valid; </li>
631
+
<li>
632
+
this expression is <code>noexcept</code>; </li>
633
+
<li>
634
+
the expression’s type satisfies <code>scheduler</code>. </li>
<p>The expression <code>get_stop_token(<em>env</em>)</code> yields the stop token associated with <code><em>env</em></code>. The value is the result of the expression <code>as_const(<em>env</em>).query(get_stop_token)</code> if </p><ul>
642
+
<li>
643
+
the expression is valid; </li>
644
+
<li>
645
+
the expression is <code>noexcept</code>; </li>
646
+
<li>
647
+
the expression satisfies <code>stoppable_token</code>. </li>
648
+
</ul>
649
+
<p>Otherwise the value is <code>never_stop_token{}</code>. </p>
<p>The expression <code>set_error(<em>receiver</em>, <em>error</em>)</code> invokes the <code>set_error</code> completion signal on <code><em>receiver</em></code> with the argument <code><em>error</em></code>, i.e., it invokes <code><em>receiver</em>.set_error(<em>error</em>)</code>. </p>
<p>The expression <code>set_stopped(<em>receiver</em>)</code> invokes the <code>set_stopped</code> completion signal on <code><em>receiver</em></code>, i.e., it invokes <code><em>receiver</em>.set_stopped()</code>. </p>
<p>The expression <code>set_value(<em>receiver</em>, <em>value</em>...)</code> invokes the <code>set_value</code> completion signal on <code><em>receiver</em></code> with the argument(s) <code><em>value</em>...</code>, i.e., it invokes <code><em>receiver</em>.set_value(<em>value</em>...)</code>. </p>
<p>The expression <code>start(<em>state</em>)</code> starts the execution of the <code>operation_state</code> object <code><em>state</em></code>. Once this expression started executing the object <code><em>state</em></code> is required to stay valid at least until one of the completion signals of <code><em>state</em></code>’s <code>receiver</code> is invoked. Once started exactly one of the completion signals is eventually called. </p>
0 commit comments