Boost logo

Boost :

From: Klemens Morgenstern (klemensdavidmorgenstern_at_[hidden])
Date: 2023-07-27 01:42:54


On Wed, Jul 26, 2023 at 11:25 PM Christian Mazakas via Boost
<boost_at_[hidden]> wrote:
>
> > I know you want to use io_uring and you seem to think you can't.
> > What's the issue with creating your own awaitables that use io_uring
> > and co_await them from async's coroutines?
>
> Actually, this would be a great test.

See what richard said: you can have asio run on io_uring already. You can then

>
> I tried reading the docs but I'm not sure how to actually author this.
>
> So, Async runs in its own event loop. In this case, I want a separate
> thread with its own io_uring event loop. Something simple that
> basically just calls:
>
> while(true) { io_uring_wait_cqe( ... );
>
> Unfortunately, this means I now _have_ to introduce thread synchronization
> latency when I'd like to use my own event loop here.

If you want to use your own event loop, you can write an executor for it, too.
Richard layed that out here:
https://cppalliance.org/richard/2020/10/31/RichardsOctoberUpdate.html

This will still use asio::any_io_executor which will incur a runtime
overhead since it's type erased.

I have put a global `executor` type into async, so that you can
replace this ( see here)
https://github.com/klemens-morgenstern/async/blob/master/include/boost/async/config.hpp#L58
but I don't know what a good solution (i.e. acceptable for boost) is
to allow a user to get his own type alias in there, because he'll need
an include.

>
> Aside from that, I can write an awaitable that communicates with the
> io_uring context
> in the awaitable's `await_suspend` but I'm not sure how to get Async
> to know when
> to resume the awaiting coroutine. What would I wind up doing here?

Most likely UB. The await_suspend(std::coroutine_handle<T> h)
can however grab the executor from the promise,
by calling h.promise().get_executor() (after checking with a requires
statement) if you need to post back.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk