diff --git a/README.md b/README.md index 63a125fb..aebaaf14 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ Using these operations some fundamental algorithms are implemented, e.g.: - `just(args...)` as the starting point of a work graph without a - specified scheduler`. + specified scheduler. - `let_value(sender, fun)` to produce a sender based on `sender`'s results. - `starts_on(scheduler, sender)` to start `sender` on `scheduler`. diff --git a/include/beman/execution/detail/continues_on.hpp b/include/beman/execution/detail/continues_on.hpp index 9bfeed3f..70db1ef0 100644 --- a/include/beman/execution/detail/continues_on.hpp +++ b/include/beman/execution/detail/continues_on.hpp @@ -35,6 +35,7 @@ import beman.execution.detail.get_completion_domain; import beman.execution.detail.get_completion_scheduler; import beman.execution.detail.get_completion_signatures; import beman.execution.detail.get_env; +import beman.execution.detail.hide_sched; import beman.execution.detail.impls_for; import beman.execution.detail.join_env; import beman.execution.detail.make_sender; @@ -49,6 +50,7 @@ import beman.execution.detail.schedule; import beman.execution.detail.schedule_from; import beman.execution.detail.schedule_result_t; import beman.execution.detail.scheduler; +import beman.execution.detail.sched_env; import beman.execution.detail.sender; import beman.execution.detail.sender_adaptor_closure; import beman.execution.detail.sender_in; @@ -71,6 +73,7 @@ import beman.execution.detail.start; #include #include #include +#include #include #include #include @@ -84,6 +87,7 @@ import beman.execution.detail.start; #include #include #include +#include #include #include #include @@ -155,23 +159,33 @@ struct continues_on_t { template struct attrs { + template + auto wrap_env(const Env& env) const noexcept { + using tag_t = ::std::conditional_t<::std::same_as, ::beman::execution::set_value_t, Tag>; + if constexpr (requires { ::beman::execution::get_completion_scheduler(this->child_attrs, env); }) { + auto compl_sch = ::beman::execution::get_completion_scheduler(this->child_attrs, env); + return ::beman::execution::detail::join_env( + ::beman::execution::detail::sched_env(::std::move(compl_sch)), + ::beman::execution::detail::hide_sched(env)); + } else { + return ::beman::execution::detail::fwd_env(env); + } + } + template - requires requires(const Scheduler& scheduler, const Env&... env) { - ::beman::execution::get_completion_scheduler(scheduler, - ::beman::execution::detail::fwd_env(env)...); + requires requires(const attrs& self, const Scheduler& scheduler, const Env&... env) { + ::beman::execution::get_completion_scheduler(scheduler, self.template wrap_env(env)...); } auto query(::beman::execution::get_completion_scheduler_t, const Env&... env) const noexcept { - return ::beman::execution::get_completion_scheduler(this->sch, - ::beman::execution::detail::fwd_env(env)...); + return ::beman::execution::get_completion_scheduler(this->sch, this->template wrap_env(env)...); } template - requires requires(const Scheduler& scheduler, const Env&... env) { - ::beman::execution::get_completion_domain(scheduler, ::beman::execution::detail::fwd_env(env)...); + requires requires(const attrs& self, const Scheduler& scheduler, const Env&... env) { + ::beman::execution::get_completion_domain(scheduler, self.template wrap_env(env)...); } auto query(::beman::execution::get_completion_domain_t, const Env&... env) const noexcept { - return ::beman::execution::get_completion_domain(this->sch, - ::beman::execution::detail::fwd_env(env)...); + return ::beman::execution::get_completion_domain(this->sch, this->template wrap_env(env)...); } template diff --git a/include/beman/execution/detail/get_domain.hpp b/include/beman/execution/detail/get_domain.hpp index 1572e7a9..51325e24 100644 --- a/include/beman/execution/detail/get_domain.hpp +++ b/include/beman/execution/detail/get_domain.hpp @@ -16,14 +16,14 @@ import std; import beman.execution.detail.default_domain; import beman.execution.detail.forwarding_query; import beman.execution.detail.get_completion_domain; -import beman.execution.detail.get_scheduler; +import beman.execution.detail.get_start_scheduler; import beman.execution.detail.hide_sched; import beman.execution.detail.set_value; #else #include #include #include -#include +#include #include #include #endif @@ -40,20 +40,20 @@ struct get_domain_t : ::beman::execution::forwarding_query_t { return type{}; } else if constexpr (requires { ::beman::execution::get_completion_domain<::beman::execution::set_value_t>( - ::beman::execution::get_scheduler(env), + ::beman::execution::get_start_scheduler(env), ::beman::execution::detail::hide_sched(env)); }) { using type = decltype(auto(::beman::execution::get_completion_domain<::beman::execution::set_value_t>( - ::beman::execution::get_scheduler(env), ::beman::execution::detail::hide_sched(env)))); + ::beman::execution::get_start_scheduler(env), ::beman::execution::detail::hide_sched(env)))); static_assert(noexcept(type{})); return type{}; } else if constexpr (requires { ::beman::execution::get_completion_domain<::beman::execution::set_value_t>( - ::beman::execution::get_scheduler(env), + ::beman::execution::get_start_scheduler(env), ::beman::execution::detail::hide_sched(env)); }) { using type = decltype(auto(::beman::execution::get_completion_domain<::beman::execution::set_value_t>( - ::beman::execution::get_scheduler(env), ::beman::execution::detail::hide_sched(env)))); + ::beman::execution::get_start_scheduler(env), ::beman::execution::detail::hide_sched(env)))); static_assert(noexcept(type{})); return type{}; } else { diff --git a/include/beman/execution/detail/get_start_scheduler.hpp b/include/beman/execution/detail/get_start_scheduler.hpp index 5df9e5b8..537b18f6 100644 --- a/include/beman/execution/detail/get_start_scheduler.hpp +++ b/include/beman/execution/detail/get_start_scheduler.hpp @@ -20,7 +20,7 @@ import beman.execution.detail.scheduler; // ---------------------------------------------------------------------------- -namespace beman::execution { +namespace beman::execution::detail { struct get_start_scheduler_t : ::beman::execution::forwarding_query_t { template requires requires(const get_start_scheduler_t& self, const Env& env) { @@ -31,7 +31,10 @@ struct get_start_scheduler_t : ::beman::execution::forwarding_query_t { return ::std::as_const(env).query(*this); } }; +} // namespace beman::execution::detail +namespace beman::execution { +using get_start_scheduler_t = ::beman::execution::detail::get_start_scheduler_t; inline constexpr get_start_scheduler_t get_start_scheduler{}; } // namespace beman::execution diff --git a/include/beman/execution/detail/hide_sched.hpp b/include/beman/execution/detail/hide_sched.hpp index 76f38110..01adb999 100644 --- a/include/beman/execution/detail/hide_sched.hpp +++ b/include/beman/execution/detail/hide_sched.hpp @@ -21,7 +21,7 @@ import beman.execution.detail.queryable; namespace beman::execution::detail { struct get_domain_t; -struct get_scheduler_t; +struct get_start_scheduler_t; template <::beman::execution::detail::queryable Q> struct hide_sched_t { @@ -35,7 +35,7 @@ struct hide_sched_t { auto query(::beman::execution::detail::get_domain_t, Args&&... args) const noexcept -> void = delete; template - auto query(::beman::execution::detail::get_scheduler_t, Args&&... args) const noexcept -> void = delete; + auto query(::beman::execution::detail::get_start_scheduler_t, Args&&... args) const noexcept -> void = delete; const Q& q; }; diff --git a/include/beman/execution/detail/inline_attrs.hpp b/include/beman/execution/detail/inline_attrs.hpp index 5e2988f4..1bd6b2bd 100644 --- a/include/beman/execution/detail/inline_attrs.hpp +++ b/include/beman/execution/detail/inline_attrs.hpp @@ -9,12 +9,12 @@ import beman.execution.detail.get_completion_domain; import beman.execution.detail.get_completion_scheduler; import beman.execution.detail.get_domain; -import beman.execution.detail.get_scheduler; +import beman.execution.detail.get_start_scheduler; #else #include #include #include -#include +#include #endif // ---------------------------------------------------------------------------- @@ -24,14 +24,14 @@ namespace beman::execution::detail { template struct inline_attrs { template - requires requires(const Env& env) { ::beman::execution::get_scheduler(env); } - constexpr auto query(const ::beman::execution::get_completion_scheduler_t&, const Env& env) const noexcept { - return ::beman::execution::get_scheduler(env); + requires requires(const Env& env) { ::beman::execution::get_start_scheduler(env); } + static constexpr auto query(const ::beman::execution::get_completion_scheduler_t&, const Env& env) noexcept { + return ::beman::execution::get_start_scheduler(env); } template requires requires(const Env& env) { ::beman::execution::get_domain(env); } - constexpr auto query(const ::beman::execution::get_completion_domain_t&, const Env& env) const noexcept { + static constexpr auto query(const ::beman::execution::get_completion_domain_t&, const Env& env) noexcept { return ::beman::execution::get_domain(env); } }; diff --git a/include/beman/execution/detail/inline_scheduler.hpp b/include/beman/execution/detail/inline_scheduler.hpp index 0e6129a5..b6ccfdd1 100644 --- a/include/beman/execution/detail/inline_scheduler.hpp +++ b/include/beman/execution/detail/inline_scheduler.hpp @@ -18,7 +18,7 @@ import beman.execution.detail.get_forward_progress_guarantee; import beman.execution.detail.get_completion_domain; import beman.execution.detail.get_completion_scheduler; import beman.execution.detail.get_domain; -import beman.execution.detail.get_scheduler; +import beman.execution.detail.get_start_scheduler; import beman.execution.detail.inline_attrs; import beman.execution.detail.operation_state; import beman.execution.detail.receiver; @@ -32,7 +32,7 @@ import beman.execution.detail.set_value; #include #include #include -#include +#include #include #include #include @@ -54,10 +54,10 @@ struct inline_scheduler { } template - requires requires(const Env& env) { ::beman::execution::get_scheduler(env); } + requires requires(const Env& env) { ::beman::execution::get_start_scheduler(env); } static auto query(const ::beman::execution::get_completion_scheduler_t<::beman::execution::set_value_t>&, const Env& env) noexcept { - return ::beman::execution::get_scheduler(env); + return ::beman::execution::get_start_scheduler(env); } template @@ -89,8 +89,6 @@ struct inline_scheduler { -> state { return {::std::forward(receiver)}; } - - inline_scheduler query(const ::beman::execution::get_scheduler_t&) const noexcept { return {}; } }; static constexpr auto schedule() noexcept -> sender { return {}; } diff --git a/include/beman/execution/detail/just.hpp b/include/beman/execution/detail/just.hpp index 76e5e72e..bdbc8e9a 100644 --- a/include/beman/execution/detail/just.hpp +++ b/include/beman/execution/detail/just.hpp @@ -18,6 +18,7 @@ import beman.execution.detail.completion_signatures; import beman.execution.detail.completion_signatures_for; import beman.execution.detail.default_impls; import beman.execution.detail.impls_for; +import beman.execution.detail.inline_attrs; import beman.execution.detail.make_sender; import beman.execution.detail.movable_value; import beman.execution.detail.product_type; @@ -29,6 +30,7 @@ import beman.execution.detail.set_value; #include #include #include +#include #include #include #include @@ -77,6 +79,13 @@ struct just_t { return typename get_signatures<::std::remove_cvref_t>::type{}; } struct impls_for : ::beman::execution::detail::default_impls { + struct get_attrs_impl { + auto operator()(const auto&) const noexcept -> ::beman::execution::detail::inline_attrs { + return {}; + } + }; + static constexpr auto get_attrs{get_attrs_impl{}}; + struct start_impl { template auto operator()(State& state, auto& receiver) const noexcept -> void { diff --git a/include/beman/execution/detail/on.hpp b/include/beman/execution/detail/on.hpp index 17cfef6f..3c5e8faa 100644 --- a/include/beman/execution/detail/on.hpp +++ b/include/beman/execution/detail/on.hpp @@ -77,7 +77,7 @@ struct on_t : ::beman::execution::sender_adaptor_closure { if constexpr (::beman::execution::scheduler) { return ::std::bool_constant<::std::invocable<::beman::execution::get_start_scheduler_t, Env>>{}; } else { - ::std::bool_constant< + return ::std::bool_constant< ::std::invocable<::beman::execution::get_completion_scheduler_t<::beman::execution::set_value_t>, ::beman::execution::env_of_t, Env>>{}; diff --git a/include/beman/execution/detail/read_env.hpp b/include/beman/execution/detail/read_env.hpp index 02419372..d2dc3a26 100644 --- a/include/beman/execution/detail/read_env.hpp +++ b/include/beman/execution/detail/read_env.hpp @@ -20,7 +20,11 @@ import beman.execution.detail.completion_signatures_for; import beman.execution.detail.data_type; import beman.execution.detail.default_impls; import beman.execution.detail.env_of_t; +import beman.execution.detail.get_completion_domain; +import beman.execution.detail.get_completion_scheduler; +import beman.execution.detail.get_domain; import beman.execution.detail.get_env; +import beman.execution.detail.get_start_scheduler; import beman.execution.detail.impls_for; import beman.execution.detail.make_sender; import beman.execution.detail.sender; @@ -32,7 +36,11 @@ import beman.execution.detail.set_value; #include #include #include +#include +#include +#include #include +#include #include #include #include @@ -71,6 +79,37 @@ struct read_env_t { return typename get_signatures<::std::remove_cvref_t, Env>::type{}; } struct impls_for : ::beman::execution::detail::default_impls { + template + struct attrs { + template + requires requires(const Env& env) { ::beman::execution::get_start_scheduler(env); } && + (::std::same_as || + (!::std::is_nothrow_invocable_v && + ::std::same_as)) + constexpr auto query(const ::beman::execution::get_completion_scheduler_t&, + const Env& env) const noexcept { + return ::beman::execution::get_start_scheduler(env); + } + + template + requires requires(const Env& env) { ::beman::execution::get_domain(env); } && + (::std::same_as || + (!::std::is_nothrow_invocable_v && + ::std::same_as)) + constexpr auto query(const ::beman::execution::get_completion_domain_t&, + const Env& env) const noexcept { + return ::beman::execution::get_domain(env); + } + }; + + struct get_attrs_impl { + template + auto operator()(const Query&) const noexcept { + return attrs{}; + } + }; + static constexpr auto get_attrs{get_attrs_impl{}}; + struct start_impl { template auto operator()(Query query, Receiver& receiver) const noexcept -> void { diff --git a/include/beman/execution/detail/sched_env.hpp b/include/beman/execution/detail/sched_env.hpp index 2631119d..35e82955 100644 --- a/include/beman/execution/detail/sched_env.hpp +++ b/include/beman/execution/detail/sched_env.hpp @@ -12,11 +12,9 @@ import std; #include #endif #ifdef BEMAN_HAS_MODULES -import beman.execution.detail.default_domain; import beman.execution.detail.get_domain; import beman.execution.detail.get_start_scheduler; #else -#include #include #include #endif @@ -31,15 +29,14 @@ class sched_env { public: template - explicit sched_env(S sch) noexcept(std::is_nothrow_constructible_v) : sched(::std::move(sch)) {} + explicit sched_env(S sch) noexcept(::std::is_nothrow_constructible_v) : sched(::std::move(sch)) {} auto query(::beman::execution::get_start_scheduler_t) const noexcept { return this->sched; } - auto query(::beman::execution::get_domain_t q) const noexcept { - if constexpr (requires { this->sched.query(q); }) - return this->sched.query(q); - else - return ::beman::execution::default_domain{}; + auto query(::beman::execution::get_domain_t q) const noexcept + requires requires { this->sched.query(q); } + { + return this->sched.query(q); } }; diff --git a/tests/beman/execution/exec-continues-on.test.cpp b/tests/beman/execution/exec-continues-on.test.cpp index a5edc2bb..aa80f101 100644 --- a/tests/beman/execution/exec-continues-on.test.cpp +++ b/tests/beman/execution/exec-continues-on.test.cpp @@ -99,6 +99,15 @@ auto test_use(Scheduler&& scheduler, Sender&& sender) { //-dk:TODO test_std::sync_wait(std::move(s)); } +auto test_inline_scheduler() { + test_std::run_loop loop; + auto sndr = test_std::continues_on(test_std::schedule(loop.get_scheduler()), test_std::inline_scheduler{}); + auto env = test_std::prop{test_std::get_start_scheduler, scheduler{}}; + auto sch = test_std::get_completion_scheduler(test_std::get_env(sndr), env); + static_assert(std::same_as); + ASSERT(sch == loop.get_scheduler()); +} + auto test_continues_on_attributes() { test_std::run_loop loop; test::sender_env s{42}; @@ -122,5 +131,6 @@ TEST(exec_continues_on) { test_constraints(scheduler{}, sender{}); test_use(scheduler{}, sender{}); + test_inline_scheduler(); test_continues_on_attributes(); } diff --git a/tests/beman/execution/exec-dependent-sender.test.cpp b/tests/beman/execution/exec-dependent-sender.test.cpp index 2c94898b..9e1b31c8 100644 --- a/tests/beman/execution/exec-dependent-sender.test.cpp +++ b/tests/beman/execution/exec-dependent-sender.test.cpp @@ -12,6 +12,7 @@ import std; import beman.execution; #else #include +#include #include #include #include diff --git a/tests/beman/execution/exec-get-domain.test.cpp b/tests/beman/execution/exec-get-domain.test.cpp index 925bd56f..215cc348 100644 --- a/tests/beman/execution/exec-get-domain.test.cpp +++ b/tests/beman/execution/exec-get-domain.test.cpp @@ -87,9 +87,9 @@ inline auto test_scheduler::schedule() const -> test_sched_sender { return {}; } static_assert(test_std::scheduler); -// Env that has get_scheduler but no get_domain +// Env that has get_start_scheduler but no get_domain struct env_with_scheduler { - auto query(test_std::get_scheduler_t) const noexcept { return test_scheduler{}; } + auto query(test_std::get_start_scheduler_t) const noexcept { return test_scheduler{}; } }; } // namespace diff --git a/tests/beman/execution/exec-inline-scheduler.test.cpp b/tests/beman/execution/exec-inline-scheduler.test.cpp index 7a8765e3..fb0a74c1 100644 --- a/tests/beman/execution/exec-inline-scheduler.test.cpp +++ b/tests/beman/execution/exec-inline-scheduler.test.cpp @@ -160,16 +160,13 @@ auto test_sender_env_is_inline_attrs() { auto sndr = test_std::schedule(test_std::inline_scheduler{}); auto attrs = test_std::get_env(sndr); static_assert(std::same_as>); - - auto sched = test_std::get_completion_scheduler(test_std::get_env(sndr), sndr); - static_assert(std::same_as); } auto test_inline_attrs_completion_scheduler() { auto attrs = test_detail::inline_attrs{}; struct test_env { - auto query(test_std::get_scheduler_t) const noexcept { return custom_scheduler{42}; } + auto query(test_std::get_start_scheduler_t) const noexcept { return custom_scheduler{42}; } }; auto sched = attrs.query(test_std::get_completion_scheduler, test_env{}); @@ -202,7 +199,7 @@ auto test_get_completion_scheduler_with_env() { auto attrs = test_std::get_env(sndr); struct test_env { - auto query(test_std::get_scheduler_t) const noexcept { return custom_scheduler{7}; } + auto query(test_std::get_start_scheduler_t) const noexcept { return custom_scheduler{7}; } }; auto sched = test_std::get_completion_scheduler(attrs, test_env{}); diff --git a/tests/beman/execution/exec-just.test.cpp b/tests/beman/execution/exec-just.test.cpp index 309633dd..894d9b14 100644 --- a/tests/beman/execution/exec-just.test.cpp +++ b/tests/beman/execution/exec-just.test.cpp @@ -3,6 +3,7 @@ #include #include +#include #include #ifdef BEMAN_HAS_IMPORT_STD import std; @@ -164,6 +165,33 @@ auto test_just() -> void { test_just_stopped(); } +auto test_just_attrs() -> void { + test::thread_pool pool; + struct test_domain : test_std::default_domain {}; + struct test_env { + auto query(test_std::get_start_scheduler_t) const noexcept { return sch; } + static auto query(test_std::get_domain_t) noexcept { return test_domain{}; } + + test::thread_pool::scheduler sch; + }; + test_env env{pool.get_scheduler()}; + auto domain1 = test_std::get_completion_domain(test_std::get_env(test_std::just()), env); + auto domain2 = + test_std::get_completion_domain(test_std::get_env(test_std::just_error(0)), env); + auto domain3 = + test_std::get_completion_domain(test_std::get_env(test_std::just_stopped()), env); + static_assert(std::same_as); + static_assert(std::same_as); + static_assert(std::same_as); + + auto sch1 = test_std::get_completion_scheduler(test_std::get_env(test_std::just()), env); + auto sch2 = + test_std::get_completion_scheduler(test_std::get_env(test_std::just_error(0)), env); + auto sch3 = + test_std::get_completion_scheduler(test_std::get_env(test_std::just_stopped()), env); + ASSERT(pool.get_scheduler() == sch1 && sch1 == sch2 && sch2 == sch3); +} + struct memory_env { std::pmr::polymorphic_allocator<> allocator; auto query(const test_std::get_allocator_t&) const noexcept { return allocator; } @@ -225,6 +253,7 @@ TEST(exec_just) { try { test_just_constraints(); test_just(); + test_just_attrs(); test_completion_signatures(); test_just_allocator(); } catch (...) { diff --git a/tests/beman/execution/exec-on.test.cpp b/tests/beman/execution/exec-on.test.cpp index 60de28d7..8eb835a8 100644 --- a/tests/beman/execution/exec-on.test.cpp +++ b/tests/beman/execution/exec-on.test.cpp @@ -156,44 +156,39 @@ TEST(exec_on) { return 42; })) | test_std::then([&cont_id](int val) { - assert(val == 42); + ASSERT(val == 42); cont_id = std::this_thread::get_id(); })); - assert(on_id == pool_id); - assert(cont_id == std::this_thread::get_id()); - assert(on_id != std::this_thread::get_id()); + ASSERT(on_id == pool_id); + ASSERT(cont_id == std::this_thread::get_id()); + ASSERT(on_id != std::this_thread::get_id()); -#if 0 -//-dk:TODO test_std::sync_wait(test_std::on(test_std::just(17), pool.get_scheduler(), test_std::then([&on_id](int val) { - assert(val == 17); + ASSERT(val == 17); on_id = std::this_thread::get_id(); return 42; })) | test_std::then([&cont_id](int val) { - assert(val == 42); + ASSERT(val == 42); cont_id = std::this_thread::get_id(); })); -#endif - assert(on_id == pool_id); - assert(cont_id == std::this_thread::get_id()); - assert(on_id != std::this_thread::get_id()); + ASSERT(on_id == pool_id); + ASSERT(cont_id == std::this_thread::get_id()); + ASSERT(on_id != std::this_thread::get_id()); -#if 0 - //-dk:TODO test_std::sync_wait(test_std::just(17) | test_std::on(pool.get_scheduler(), test_std::then([&on_id](int val) { - assert(val == 17); + ASSERT(val == 17); + on_id = std::this_thread::get_id(); return 42; })) | test_std::then([&cont_id](int val) { - assert(val == 42); + ASSERT(val == 42); cont_id = std::this_thread::get_id(); })); -#endif - assert(on_id == pool_id); - assert(cont_id == std::this_thread::get_id()); - assert(on_id != std::this_thread::get_id()); + ASSERT(on_id == pool_id); + ASSERT(cont_id == std::this_thread::get_id()); + ASSERT(on_id != std::this_thread::get_id()); test_on_attributes(); } diff --git a/tests/beman/execution/exec-parallel-scheduler.test.cpp b/tests/beman/execution/exec-parallel-scheduler.test.cpp index 288b0d97..86a3259f 100644 --- a/tests/beman/execution/exec-parallel-scheduler.test.cpp +++ b/tests/beman/execution/exec-parallel-scheduler.test.cpp @@ -189,6 +189,24 @@ auto test_parallel_scheduler_schedule() -> void { ASSERT((vec == std::vector{2, 4, 6, 8})); } } + { + auto sndr = test_std::schedule(sch) | test_std::continues_on(test_std::inline_scheduler{}); + auto attrs = test_std::get_env(sndr); + auto compl_sch = test_std::get_completion_scheduler(attrs, test_std::env{}); + ASSERT(compl_sch == sch); + using psched_domain = decltype(test_std::get_completion_domain<>(sch)); + using compl_domain = decltype(test_std::get_completion_domain<>(attrs, test_std::env{})); + static_assert(std::same_as); + } + { + auto sndr = test_std::starts_on(test_std::inline_scheduler{}, test_std::schedule(sch)); + auto attrs = test_std::get_env(sndr); + auto compl_sch = test_std::get_completion_scheduler(attrs, test_std::env{}); + ASSERT(compl_sch == sch); + using psched_domain = decltype(test_std::get_completion_domain<>(sch)); + using compl_domain = decltype(test_std::get_completion_domain<>(attrs, test_std::env{})); + static_assert(std::same_as); + } } } // namespace diff --git a/tests/beman/execution/exec-queries-expos.test.cpp b/tests/beman/execution/exec-queries-expos.test.cpp index 06acee24..491397cb 100644 --- a/tests/beman/execution/exec-queries-expos.test.cpp +++ b/tests/beman/execution/exec-queries-expos.test.cpp @@ -4,12 +4,12 @@ #include #ifdef BEMAN_HAS_MODULES import beman.execution.detail.get_domain; -import beman.execution.detail.get_scheduler; +import beman.execution.detail.get_start_scheduler; import beman.execution.detail.hide_sched; import beman.execution.detail.try_query; #else #include -#include +#include #include #include #endif @@ -37,9 +37,9 @@ struct test_queryable { int query(test_std::get_domain_t, arg<0>) const noexcept { return 48; } int query(test_std::get_domain_t, arg<0>, arg<1>) const noexcept { return 49; } - int query(test_std::get_scheduler_t) const noexcept { return 50; } - int query(test_std::get_scheduler_t, arg<0>) const noexcept { return 51; } - int query(test_std::get_scheduler_t, arg<0>, arg<1>) const noexcept { return 52; } + int query(test_std::get_start_scheduler_t) const noexcept { return 50; } + int query(test_std::get_start_scheduler_t, arg<0>) const noexcept { return 51; } + int query(test_std::get_start_scheduler_t, arg<0>, arg<1>) const noexcept { return 52; } }; template @@ -84,9 +84,9 @@ auto test_hide_query() -> void { test_hide_query_exists(48, test_queryable{}, test_std::get_domain, arg<0>{}); test_hide_query_exists(49, test_queryable{}, test_std::get_domain, arg<0>{}, arg<1>{}); - test_hide_query_exists(50, test_queryable{}, test_std::get_scheduler); - test_hide_query_exists(51, test_queryable{}, test_std::get_scheduler, arg<0>{}); - test_hide_query_exists(52, test_queryable{}, test_std::get_scheduler, arg<0>{}, arg<1>{}); + test_hide_query_exists(50, test_queryable{}, test_std::get_start_scheduler); + test_hide_query_exists(51, test_queryable{}, test_std::get_start_scheduler, arg<0>{}); + test_hide_query_exists(52, test_queryable{}, test_std::get_start_scheduler, arg<0>{}, arg<1>{}); } } // namespace diff --git a/tests/beman/execution/exec-read-env.test.cpp b/tests/beman/execution/exec-read-env.test.cpp index 2655adbb..5e7a35da 100644 --- a/tests/beman/execution/exec-read-env.test.cpp +++ b/tests/beman/execution/exec-read-env.test.cpp @@ -93,6 +93,29 @@ auto test_read_env_concept() -> void { static_assert(test_std::sender_in); } +template +struct test_receiver { + using receiver_concept = test_std::receiver_tag; + + auto get_env() const noexcept { return env; } + + auto set_value(const auto& value) const noexcept -> void { ASSERT(value == expected); } + + Expected expected; + Env env; +}; + +auto test_read_env_attrs() -> void { + test_std::run_loop loop; + auto env = test_std::prop{test_std::get_start_scheduler, loop.get_scheduler()}; + auto sndr = test_std::read_env(test_std::get_start_scheduler); + auto expected = test_std::get_completion_scheduler(test_std::get_env(sndr), env); + test_receiver rcvr{expected, env}; + auto op = test_std::connect(sndr, std::move(rcvr)); + test_std::start(op); + ASSERT(loop.get_scheduler() == expected); +} + auto test_read_env() -> void { static_assert(test_std::receiver); ASSERT(domain{} == test_std::get_domain(env{17})); @@ -176,6 +199,7 @@ auto test_read_env_check_types() -> void { TEST(exec_read_env) { static_assert(std::same_as); test_read_env_concept(); + test_read_env_attrs(); test_read_env(); test_read_env_completions(); test_read_env_check_types(); diff --git a/tests/beman/execution/exec-snd-expos.test.cpp b/tests/beman/execution/exec-snd-expos.test.cpp index b9407f8c..3f6383bc 100644 --- a/tests/beman/execution/exec-snd-expos.test.cpp +++ b/tests/beman/execution/exec-snd-expos.test.cpp @@ -377,9 +377,6 @@ struct env { } // namespace completion_domain auto test_compl_domain() -> void { namespace cd = completion_domain; - static_assert( - std::same_as(test_std::just(), test_std::env<>())), - decltype(test_std::indeterminate_domain())>); static_assert(requires { test_std::get_completion_domain(test_std::get_env(cd::sender()));