Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing environment in sync_wait #108

Merged
merged 3 commits into from
Dec 23, 2024
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
5 changes: 4 additions & 1 deletion include/beman/execution26/detail/sync_wait.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Sender,
::beman::execution26::detail::sync_wait_env,
Expand Down Expand Up @@ -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 {
Expand Down
14 changes: 14 additions & 0 deletions tests/beman/execution26/exec-sync-wait.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
#include <beman/execution26/detail/sender.hpp>
#include <beman/execution26/detail/sender_in.hpp>
#include <beman/execution26/detail/just.hpp>
#include <beman/execution26/detail/read_env.hpp>
#include <beman/execution26/detail/get_delegation_scheduler.hpp>
#include <beman/execution26/detail/then.hpp>
#include <test/execution.hpp>

#include <exception>
Expand Down Expand Up @@ -223,6 +226,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) {
Expand All @@ -236,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();
}
Loading