Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions include/beman/execution/detail/run_loop.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import beman.execution.detail.set_value;
import beman.execution.detail.unstoppable_token;
#else
#include <beman/execution/detail/completion_signatures.hpp>
#include <beman/execution/detail/env.hpp>
#include <beman/execution/detail/get_completion_scheduler.hpp>
#include <beman/execution/detail/get_env.hpp>
#include <beman/execution/detail/get_forward_progress_guarantee.hpp>
Expand Down Expand Up @@ -90,10 +91,20 @@ class run_loop {
};
struct sender {
using sender_concept = ::beman::execution::sender_tag;
template <typename, typename... Env>
template <typename Self, typename... Env>
static consteval auto get_completion_signatures() noexcept {
if constexpr (::beman::execution::unstoppable_token<decltype(::beman::execution::get_stop_token(
std::declval<Env>()...))>)
// [exec.getcomplsigs] permits sizeof...(Env) == 0. Answering that

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This amount of comment is probably not actually warranted.

// query as if for env<> matches [exec.run.loop]'s formula, whose
// E = env<> has an unstoppable stop token, and matches how the
// other environment-sensitive senders here (then, into_variant)
// handle the empty pack. Without this the member's body is
// ill-formed for an empty pack -- get_stop_token() with no
// argument -- and because the return type is deduced, that is a
// hard error rather than a substitution failure.
if constexpr (0u == sizeof...(Env))
return get_completion_signatures<Self, ::beman::execution::env<>>();
else if constexpr (::beman::execution::unstoppable_token<decltype(::beman::execution::get_stop_token(
std::declval<Env>()...))>)
return ::beman::execution::completion_signatures<::beman::execution::set_value_t()>{};
else
return ::beman::execution::completion_signatures<::beman::execution::set_value_t(),
Expand Down
11 changes: 11 additions & 0 deletions tests/beman/execution/exec-run-loop-types.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import beman.execution;
#include <beman/execution/detail/inplace_stop_source.hpp>
#include <beman/execution/detail/completion_signatures.hpp>
#include <beman/execution/detail/connect.hpp>
#include <beman/execution/detail/dependent_sender.hpp>
#include <beman/execution/detail/start.hpp>
#include <beman/execution/detail/get_completion_signatures.hpp>
#include <beman/execution/detail/get_env.hpp>
Expand Down Expand Up @@ -98,6 +99,16 @@ TEST(exec_run_loop_types) {
::std::same_as<test_std::completion_signatures<test_std::set_value_t(), test_std::set_stopped_t()>,
decltype(test_std::get_completion_signatures<decltype(sender),
decltype(token_env{source.get_token()})>())>);
// [exec.getcomplsigs] constrains sizeof...(Env) <= 1, so the
// zero-environment query is well-formed and must be answered. It is
// answered as for env<>, whose stop token is unstoppable.
static_assert(::std::same_as<test_std::completion_signatures<test_std::set_value_t()>,
decltype(test_std::get_completion_signatures<decltype(sender)>())>);
// ... and because detail::non_dependent_sender is itself spelled with that
// query inside a requires-expression, a sender that cannot answer it makes
// the concept ill-formed rather than false. Asserting the concept is what
// pins that down.
static_assert(not test_std::dependent_sender<decltype(sender)>);
// p7:
static_assert(
test_std::receiver_of<receiver, decltype(test_std::get_completion_signatures<decltype(sender), env>())>);
Expand Down
Loading