Skip to content

Commit 8398d5a

Browse files
test: pin read_env's completion-behavior claims for get_scheduler() (#2098) (#2338)
* test: pin read_env's completion-behavior claims for get_scheduler() (#2098) read_env may advertise inline completion only for the completion tags it can actually send. When it advertised more than that, a task co_awaiting get_scheduler() | let_value(schedule) was classified as completing inline, so the awaiter kept the composed operation state in its own stack frame while a nested schedule() operation was still queued. Assert that get_scheduler() claims inline completion for set_value_t alone, and that the composed expression is not treated as completing inline. * fix(test): use module-exported names in get_scheduler() composition check The final assertion named ex::__as_awaitable::__completes_inline, which is not part of the stdexec module's exported surface: the clang-trunk modules build rejected the name ("must be declared before it is used") and nvc++ could not resolve the namespace at all ("name followed by '::' must be a class or namespace name"), failing 4 CI configurations. Replace it with assertions on the exported per-tag concept: the composition's set_value_t completes inline (let_value forwards read_env's inline value completion), while its set_stopped_t does not (the nested schedule() completes asynchronously), so a co_await on it must not be treated as completing inline. Both hold on current main and fail at 482c260. --------- Co-authored-by: alwaysprince05 <[email protected]>
1 parent dfc8c95 commit 8398d5a

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

‎test/stdexec/queries/test_get_completion_behavior.cpp‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,41 @@ static_assert(cb::__may_be_asynchronous(cb::__asynchronous_affine));
6161
static_assert(cb::__may_be_asynchronous(cb::__asynchronous | cb::__inline_completion));
6262
static_assert(cb::__may_be_asynchronous(cb::__asynchronous_affine | cb::__asynchronous));
6363
static_assert(cb::__may_be_asynchronous(cb::__asynchronous_affine | cb::__inline_completion));
64+
65+
// read_env completes in its start(), so get_scheduler() may claim inline completion
66+
// for set_value_t -- but only for the tags it can actually send. Advertising
67+
// inline completion for a tag it never sends made a task that co_awaits
68+
// get_scheduler() | let_value(schedule) look like it completed inline, and the
69+
// awaiter then kept the composed operation state in its own stack frame while a
70+
// nested schedule() operation was still queued (see #2098).
71+
using __get_scheduler_sndr_t = decltype(ex::get_scheduler());
72+
using __get_scheduler_attrs_t = ex::env_of_t<__get_scheduler_sndr_t>;
73+
74+
static_assert(ex::__completes_inline<ex::set_value_t, __get_scheduler_attrs_t>);
75+
static_assert(!ex::__completes_inline<ex::set_error_t, __get_scheduler_attrs_t>);
76+
static_assert(!ex::__completes_inline<ex::set_stopped_t, __get_scheduler_attrs_t>);
77+
78+
// The same expression from #2098, composed: the successor sender schedule(sch) may
79+
// complete asynchronously, so the composition must not be treated as completing
80+
// inline.
81+
inline constexpr auto __reschedule = [](auto __sch)
82+
{
83+
return ex::schedule(__sch);
84+
};
85+
inline constexpr auto __reschedule_on_current = ex::get_scheduler() | ex::let_value(__reschedule);
86+
87+
// For co_await, a sender is treated as completing inline only if _all_ of its
88+
// completion tags complete inline (see __as_awaitable::__completes_inline). The
89+
// nested schedule(sch) does not complete inline for set_stopped_t, so the
90+
// composition must not be classified as completing inline. We check the stopped
91+
// tag directly; the value tag of the composition _does_ complete inline
92+
// (let_value forwards read_env's inline value completion), so that is pinned
93+
// here as well. This check uses only names exported by the stdexec module: the
94+
// __as_awaitable namespace is not part of the module's public surface, and
95+
// naming it fails the modular and nvc++ configurations.
96+
static_assert(ex::__completes_inline<ex::set_value_t,
97+
ex::env_of_t<decltype(__reschedule_on_current)>,
98+
ex::env<>>);
99+
static_assert(!ex::__completes_inline<ex::set_stopped_t,
100+
ex::env_of_t<decltype(__reschedule_on_current)>,
101+
ex::env<>>);

0 commit comments

Comments
 (0)