Skip to content

Commit 5d0de33

Browse files
maikeldietmarkuehl
andauthored
Fix missing environment in sync_wait (#108)
* Fix missing environment in sync_wait * sync_wait: add tests for its environment * fixed a problem with env in sync_wait (and fixed the tests) --------- Co-authored-by: Dietmar Kühl <[email protected]>
1 parent 2d7e75e commit 5d0de33

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

include/beman/execution26/detail/sync_wait.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ struct sync_wait_env {
3232
auto query(::beman::execution26::get_delegation_scheduler_t) const noexcept { return this->loop->get_scheduler(); }
3333
};
3434

35-
template <::beman::execution26::sender_in Sender>
35+
template <::beman::execution26::sender_in<::beman::execution26::detail::sync_wait_env> Sender>
3636
using sync_wait_result_type =
3737
::std::optional<::beman::execution26::value_types_of_t<Sender,
3838
::beman::execution26::detail::sync_wait_env,
@@ -68,6 +68,9 @@ struct sync_wait_receiver {
6868
}
6969
this->state->loop.finish();
7070
}
71+
auto get_env() const noexcept -> ::beman::execution26::detail::sync_wait_env {
72+
return ::beman::execution26::detail::sync_wait_env{&this->state->loop};
73+
}
7174
};
7275

7376
struct sync_wait_t {

tests/beman/execution26/exec-sync-wait.test.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
#include <beman/execution26/detail/sender.hpp>
1414
#include <beman/execution26/detail/sender_in.hpp>
1515
#include <beman/execution26/detail/just.hpp>
16+
#include <beman/execution26/detail/read_env.hpp>
17+
#include <beman/execution26/detail/get_delegation_scheduler.hpp>
18+
#include <beman/execution26/detail/then.hpp>
1619
#include <test/execution.hpp>
1720

1821
#include <exception>
@@ -223,6 +226,15 @@ auto test_sync_wait() -> void {
223226
// NOLINTEND(cert-dcl03-c,hicpp-static-assert,misc-static-assert)
224227
}
225228
}
229+
230+
auto test_provides_scheduler() -> void {
231+
ASSERT(test_std::sync_wait(test_std::then(test_std::read_env(test_std::get_scheduler), [](auto&&) noexcept {})));
232+
}
233+
234+
auto test_provides_delegation_scheduler() -> void {
235+
ASSERT(test_std::sync_wait(
236+
test_std::then(test_std::read_env(test_std::get_delegation_scheduler), [](auto&&) noexcept {})));
237+
}
226238
} // namespace
227239

228240
TEST(exec_sync_wait) {
@@ -236,4 +248,6 @@ TEST(exec_sync_wait) {
236248
test_sync_wait_state();
237249
test_sync_wait_receiver();
238250
test_sync_wait();
251+
test_provides_scheduler();
252+
test_provides_delegation_scheduler();
239253
}

0 commit comments

Comments
 (0)