Skip to content

asio senders don't work with stdexec::task coroutines #1936

@maxbachmann

Description

@maxbachmann
stdexec::task<void> test(asio::steady_timer& timer)
{
    co_await timer.async_wait(asio::as_tuple(exec::asio::use_sender));
}

fails to compile:

stdexec/__detail/__task.hpp:503:37:   required from 'constexpr auto stdexec::task<_Ty, _Env>::__promise::await_transform(_Sender&&) [with _Sender = experimental::execution::asio::detail::use_sender::sender<experimental::execution::asio::detail::completion_token::sender<stdexec::completion_signatures<stdexec::set_value_t(std::tuple<std::error_code>), stdexec::set_error_t(std::__exception_ptr::exception_ptr), stdexec::set_stopped_t()>, asio::async_result<asio::as_tuple_t<experimental::execution::asio::use_sender_t>, void(std::error_code)>::init_wrapper<asio::basic_waitable_timer<std::chrono::_V2::steady_clock>::initiate_async_wait> > >; _Ty = void; _Env = stdexec::env<>]'
  503 |         return STDEXEC::as_awaitable(STDEXEC::affine_on(static_cast<_Sender&&>(__sndr)), *this);
test.cpp:540:69:   required from here
  540 |     co_await timer.async_wait(asio::as_tuple(exec::asio::use_sender));
      |                                                                     ^
stdexec/__detail/__get_completion_signatures.hpp:62:84: error: invalid use of void expression
   62 |     STDEXEC_PP_FRONT(__VA_ARGS__))::template get_completion_signatures<__VA_ARGS__>()
stdexec/__detail/__get_completion_signatures.hpp:66:5: note: in definition of macro 'STDEXEC_CHECKED_COMPLSIGS'
   66 |     __VA_ARGS__, static_cast<__mlist<STDEXEC_PP_EXPAND _ARGS>*>(nullptr))
      |     ^~~~~~~~~~~
stdexec/__detail/__get_completion_signatures.hpp:228:59: note: in expansion of macro 'STDEXEC_GET_COMPLSIGS'
  228 |         return STDEXEC_CHECKED_COMPLSIGS((_Sender, _Env), STDEXEC_GET_COMPLSIGS(_Sender, _Env));
      |                                                           ^~~~~~~~~~~~~~~~~~~~~
test.cpp: In function 'stdexec::task<void> test(asio::steady_timer&)':
test.cpp:540:5: error: no member named 'await_ready' in 'stdexec::{anonymous}::__sexpr<<lambda closure object>stdexec::<lambda()>()>'
  540 |     co_await timer.async_wait(asio::as_tuple(exec::asio::use_sender));
      |     ^~~~~~~~
scons: *** [test.o] Error 1

This works fine with the old exec::task

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions