Boost logo

Boost :

From: Niall Douglas (s_sourceforge_at_[hidden])
Date: 2023-08-08 05:33:22


Dear Boost,

It is my great pleasure to announce the beginning of the peer review of
proposed Boost.Async, which is hoped to become the most popular way of
programming C++ coroutines in future C++. The peer review shall run
between Tuesday 8th August and Friday 18th August.

Like many of you have found, until now there has been no good standard
and easy way of writing C++ coroutine code which works easily with
multiple third party codebases and foreign asynchronous design patterns.
ASIO’s current coroutine support is tightly coupled to ASIO, and it
rejects foreign awaitables. Libunifex is dense to master and non-obvious
to make work well with foreign asynchronous design patterns, not helped
by a lack of documentation, a problem which also afflicts stdexec which
also has a steep and dense learning curve. CppCoro is probably currently
the best in class solution to the space of easy to use fire and forget
C++ coroutine programming, but it isn’t particularly portable and was
designed long before C++ coroutine standardisation was completed.

Klemens very kindly stepped up and created for us an open source
ground-up reimplementation of the best ideas of hitherto proprietary
commercial C++ coroutine libraries, taking in experience and feedback
from multiple domain experts in the area to create an easy to use C++
coroutine support library with excellent support for foreign
asynchronous design patterns. For example, if you want your coroutine to
suspend while a stackful fiber runs and then resume when that fiber has
done something – AND that fiber implementation is unknown to Boost.Async
– this is made as easy as possible. If your C++ coroutine code wants to
await on unknown foreign awaitables, that generally “just works” with no
added effort. This makes tying together multiple third party
dependencies into a solution based on C++ coroutines much easier than
until now.

The industry standard executor is ASIO, so Boost.Async uses Boost.ASIO
as its base executor. To keep things simple and high performance,
Boost.Async requires each pool of things it works with to execute on a
single kernel thread at a time – though there can be a pool of things
per kernel thread, or an ASIO strand can ensure execution never occurs
on multiple kernel threads. The basic concurrency primitives of promise,
generator and task are provided, with the fundamental operations of
select, join and gather. Some more complex async support is supplied:
Go-type channels, and async teardown. Performance is superior to both
stackful coroutines and ASIO’s own C++ coroutine support, and sometimes
far superior.

You can read the documentation at https://klemens.dev/async/ and study
or try out the code at https://github.com/klemens-morgenstern/async.

Anyone with experience using C++ coroutines is welcome to contribute a
review at the Boost mailing list
(https://lists.boost.org/mailman/listinfo.cgi/boost), here at this
Reddit page, via email to me personally, or any other mechanism where I
the review manager will see it. In your review please state at the end
whether you recommend acceptance, acceptance with conditions, or
rejection. Please state your experience with C++ coroutines and ASIO in
your review, and how many hours you spent on the review.

Thanks in advance for your time and reviews!

Niall


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