Boost logo

Boost :

From: oliver.kowalke_at_[hidden]
Date: 2023-07-25 09:45:43


AFAIK, boost::asio::spawn() already uses boost.context internally (stackful coroutines).
So I was curious how it works with co_await as you mentioned in your post

25.07.2023 07:10:24 Klemens Morgenstern via Boost <boost_at_[hidden]>:

> Do you mean asio::spawn with async? "co_await asio::spawn(co_await
> async::this_coro::executor, my_stackful_coro, async::use_op)" would do. It
> can handle any async operation, of which asio::spawn is one.
>
> There is no integration between boost.context and async (and there can't
> be, I think). I wonder if there could be a faux-routine,
> that looks like a async-coro, but is actually a boost.context primitive
> underneath.
>
>
>
> Boost.async integrates with everything asio, through the use_op completion
> token, so you can just use it with boost.process (v2 would be recommended)
> like this:
>
> That could look akin to this:
>
> promise<void> pipe_reader(asio::readable_pipe & pr)
> {
>    std::string buffer;
>    buffer.resize(4096);
>    std::size_t n = co_await pr.async_read_some(asio::buffer(buffer),
> async::use_op);
>    // do something with the data
>    pr.close();
> }
>
> namespace vs = boost::process::v2;
> asio::readable_pipe rp{co_await async::this_coro::executor};
> v2::process proc(co_await async::this_coro::executor, "/usr/bin/cat",
> {"source.txt"}, bind_stdio{.stdout=rp});
> co_await async::join(pipe_reader(rp), proc.async_wait(async::use_op));
>
>
> On Tue, Jul 25, 2023 at 12:22 PM oliver.kowalke--- via Boost <
> boost_at_[hidden]> wrote:
>
>> Because my code relies heavily on asio's spawn() could you provide
>> examples using spawn() in the git repo?
>>
>> How does boost.async integrate boost.process? I'm especially interested in
>> adync. reading/writing from/to forked process' stdin/stout/stderr.
>>
>> Oliver
>>
>> 24.07.2023 18:59:47 Niall Douglas via Boost <boost_at_[hidden]>:
>>
>>> On 24/07/2023 15:51, Phil Endecott via Boost wrote:
>>>> Klemens Morgenstern wrote:
>>>>> I am seeking endorsement for my C++20 async coroutine library
>>>>> boost.async.
>>>>
>>>>> - coroutine types (eager, lazy, generators)
>>>>
>>>> Can the generators be used without ASIO? Are they compatible
>>>> the the C++23 std::generator?
>>>
>>> His library works without effort with all third party awaitables. This
>>> is a very big thing, previously using C++ coroutines with ASIO meant you
>>> had to use ASIO's awaitables and couldn't use any others. With this
>>> library, you can mix and match any type of awaitable freely with ASIO
>>> code. That's an enormous leap forward in C++ coroutine usability.
>>>
>>> I'll be review managing it we currently think between the 8th and 18th
>>> of August.
>>>
>>> Niall
>>>
>>> _______________________________________________
>>> Unsubscribe & other changes:
>> http://lists.boost.org/mailman/listinfo.cgi/boost
>>
>> _______________________________________________
>> Unsubscribe & other changes:
>> http://lists.boost.org/mailman/listinfo.cgi/boost
>>
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost


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