Skip to content
Open
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
12 changes: 7 additions & 5 deletions include/stdexec/__detail/__sequence.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,14 @@ namespace STDEXEC
template <class _Sender>
struct __attrs<_Sender>
{
template <class _Env2 = env_of_t<_Sender>, class _Query, class... _Args>
requires __queryable_with<_Env2, _Query, _Args...>
using _env_t = env_of_t<_Sender>;

template <class _Query, class... _Args>
requires __queryable_with<_env_t, _Query, _Args...>
STDEXEC_ATTRIBUTE(nodiscard, always_inline, host, device)
constexpr auto operator()(_Query, _Args &&...__args) const
noexcept(__nothrow_queryable_with<_Env2, _Query, _Args...>)
-> __query_result_t<_Env2, _Query, _Args...>
constexpr auto query(_Query, _Args &&...__args) const
noexcept(__nothrow_queryable_with<_env_t, _Query, _Args...>)
-> __query_result_t<_env_t, _Query, _Args...>
{
return STDEXEC::get_env(__sndr_).query(_Query(), static_cast<_Args &&>(__args)...);
}
Expand Down
42 changes: 42 additions & 0 deletions test/stdexec/algos/adaptors/test_sequence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <stdexec/execution.hpp>

#include <exec/sequence.hpp>
#include <exec/static_thread_pool.hpp>
#include <test_common/receivers.hpp>
#include <test_common/type_helpers.hpp>

Expand Down Expand Up @@ -187,3 +188,44 @@ TEST_CASE("sequence with sender with only first sender with throwing connect", "
CHECK_THROWS(ex::connect(std::move(sndr), empty_recv::recv0{}));
}
#endif // !STDEXEC_NO_STD_EXCEPTIONS()

TEST_CASE("completion domain of a sequence of one sender", "[sequence]")
{
exec::static_thread_pool pool{1};

unsigned short int value = 0;

auto sndr = exec::sequence(STDEXEC::schedule(pool.get_scheduler())
| STDEXEC::then([&]() noexcept { value = 42; }));

static_assert(
std::same_as<
STDEXEC::__completion_domain_of_t<STDEXEC::set_value_t, decltype(sndr), STDEXEC::env<>>,
experimental::execution::_pool_::_static_thread_pool::domain>);

STDEXEC::sync_wait(std::move(sndr));

CHECK(value == 42);
}

TEST_CASE("completion domain of a sequence of two senders", "[sequence]")
{
exec::static_thread_pool pool{1};

unsigned short int value_A = 0, value_B = 0;

auto sndr = exec::sequence(STDEXEC::schedule(pool.get_scheduler())
| STDEXEC::then([&]() noexcept { value_A = 42; }),
STDEXEC::schedule(pool.get_scheduler())
| STDEXEC::then([&]() noexcept { value_B = 42; }));

static_assert(
std::same_as<
STDEXEC::__completion_domain_of_t<STDEXEC::set_value_t, decltype(sndr), STDEXEC::env<>>,
experimental::execution::_pool_::_static_thread_pool::domain>);

STDEXEC::sync_wait(std::move(sndr));

CHECK(value_A == 42);
CHECK(value_B == 42);
}