Skip to content

Commit

Permalink
exec.coroutines: Address review concerns
Browse files Browse the repository at this point in the history
  • Loading branch information
maikel committed Nov 30, 2024
1 parent 54d2414 commit c2e0553
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 21 deletions.
4 changes: 2 additions & 2 deletions include/beman/execution26/detail/as_awaitable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ struct as_awaitable_t {
return ::std::forward<Expr>(expr).as_awaitable(promise);
} else if constexpr (::beman::execution26::detail::
is_awaitable<Expr, ::beman::execution26::detail::unspecified_promise>) {
return (void(promise), ::std::forward<Expr>(expr));
return ::std::forward<Expr>(expr);
} else if constexpr (::beman::execution26::detail::awaitable_sender<Expr, Promise>) {
return ::beman::execution26::detail::sender_awaitable<Expr, Promise>{::std::forward<Expr>(expr), promise};
} else {
return (void(promise), ::std::forward<Expr>(expr));
return ::std::forward<Expr>(expr);
}
}
};
Expand Down
4 changes: 2 additions & 2 deletions include/beman/execution26/detail/unspecified_promise.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
namespace beman::execution26::detail {
struct unspecified_promise {
auto get_return_object() noexcept -> unspecified_promise;
auto initial_suspend() noexcept -> unspecified_promise;
auto final_suspend() noexcept -> unspecified_promise;
auto initial_suspend() noexcept -> ::std::suspend_never;
auto final_suspend() noexcept -> ::std::suspend_never;
void unhandled_exception() noexcept;
void return_void() noexcept;
auto unhandled_stopped() noexcept -> ::std::coroutine_handle<>;
Expand Down
22 changes: 5 additions & 17 deletions tests/beman/execution26/exec-with-awaitable-senders.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ struct coroutine : std::coroutine_handle<promise> {
struct promise : exec::with_awaitable_senders<promise> {
coroutine get_return_object() { return {coroutine::from_promise(*this)}; }
std::suspend_always initial_suspend() noexcept { return {}; }
std::suspend_always final_suspend() noexcept { return {}; }
std::suspend_never final_suspend() noexcept { return {}; }
void return_void() {}
void unhandled_exception() {}
};
Expand Down Expand Up @@ -58,21 +58,9 @@ coroutine test_mix_awaitable_and_sender() {
ASSERT(value == 1);
}

int main() {
{
coroutine coro = test_await_tuple();
coro.resume();
coro.destroy();
}
{
coroutine coro = test_await_void();
coro.resume();
coro.destroy();
}
TEST(exec_with_awaitable_senders) {
test_await_tuple().resume();
test_await_void().resume();
test_sync_wait_awaitable();
{
coroutine coro = test_mix_awaitable_and_sender();
coro.resume();
coro.destroy();
}
test_mix_awaitable_and_sender().resume();
}

0 comments on commit c2e0553

Please sign in to comment.