From d4fdf1dcff37547f2342df57e46d2816c0937d29 Mon Sep 17 00:00:00 2001 From: Maikel Nadolski Date: Mon, 23 Dec 2024 05:37:01 +0100 Subject: [PATCH 1/3] Fix missing environment in sync_wait --- include/beman/execution26/detail/sync_wait.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/beman/execution26/detail/sync_wait.hpp b/include/beman/execution26/detail/sync_wait.hpp index 694eb15a..29d9d1fa 100644 --- a/include/beman/execution26/detail/sync_wait.hpp +++ b/include/beman/execution26/detail/sync_wait.hpp @@ -68,6 +68,9 @@ struct sync_wait_receiver { } this->state->loop.finish(); } + auto get_env() const noexcept -> ::beman::execution26::detail::sync_wait_env { + return ::beman::execution26::detail::sync_wait_env{&this->state->loop}; + } }; struct sync_wait_t { From 38c8d985ef7e51910d9c486a6c962b96310f9d1b Mon Sep 17 00:00:00 2001 From: Maikel Nadolski Date: Mon, 23 Dec 2024 11:27:12 +0100 Subject: [PATCH 2/3] sync_wait: add tests for its environment --- tests/beman/execution26/exec-sync-wait.test.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/beman/execution26/exec-sync-wait.test.cpp b/tests/beman/execution26/exec-sync-wait.test.cpp index 5a650b42..94592069 100644 --- a/tests/beman/execution26/exec-sync-wait.test.cpp +++ b/tests/beman/execution26/exec-sync-wait.test.cpp @@ -223,6 +223,15 @@ auto test_sync_wait() -> void { // NOLINTEND(cert-dcl03-c,hicpp-static-assert,misc-static-assert) } } + +auto test_provides_scheduler() -> void { + ASSERT(test_std::sync_wait(test_std::then(test_std::read_env(test_std::get_scheduler()), [](auto&&) noexcept {}))); +} + +auto test_provides_delegation_scheduler() -> void { + ASSERT(test_std::sync_wait( + test_std::then(test_std::read_env(test_std::get_delegation_scheduler()), [](auto&&) noexcept {}))); +} } // namespace TEST(exec_sync_wait) { From a202012e407cac30f69428864dd182c09374c62f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dietmar=20K=C3=BChl?= Date: Mon, 23 Dec 2024 14:13:44 +0100 Subject: [PATCH 3/3] fixed a problem with env in sync_wait (and fixed the tests) --- include/beman/execution26/detail/sync_wait.hpp | 2 +- tests/beman/execution26/exec-sync-wait.test.cpp | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/include/beman/execution26/detail/sync_wait.hpp b/include/beman/execution26/detail/sync_wait.hpp index 29d9d1fa..b474d988 100644 --- a/include/beman/execution26/detail/sync_wait.hpp +++ b/include/beman/execution26/detail/sync_wait.hpp @@ -32,7 +32,7 @@ struct sync_wait_env { auto query(::beman::execution26::get_delegation_scheduler_t) const noexcept { return this->loop->get_scheduler(); } }; -template <::beman::execution26::sender_in Sender> +template <::beman::execution26::sender_in<::beman::execution26::detail::sync_wait_env> Sender> using sync_wait_result_type = ::std::optional<::beman::execution26::value_types_of_t #include #include +#include +#include +#include #include #include @@ -225,12 +228,12 @@ auto test_sync_wait() -> void { } auto test_provides_scheduler() -> void { - ASSERT(test_std::sync_wait(test_std::then(test_std::read_env(test_std::get_scheduler()), [](auto&&) noexcept {}))); + ASSERT(test_std::sync_wait(test_std::then(test_std::read_env(test_std::get_scheduler), [](auto&&) noexcept {}))); } auto test_provides_delegation_scheduler() -> void { ASSERT(test_std::sync_wait( - test_std::then(test_std::read_env(test_std::get_delegation_scheduler()), [](auto&&) noexcept {}))); + test_std::then(test_std::read_env(test_std::get_delegation_scheduler), [](auto&&) noexcept {}))); } } // namespace @@ -245,4 +248,6 @@ TEST(exec_sync_wait) { test_sync_wait_state(); test_sync_wait_receiver(); test_sync_wait(); + test_provides_scheduler(); + test_provides_delegation_scheduler(); }