Boost logo

Boost Users :

From: Gavin Lambert (boost_at_[hidden])
Date: 2020-10-18 21:55:34


On 17/10/2020 05:45, David Frank wrote:
> Does boost promise/future support coroutines?
>
> For example, the get call only block the running coroutine, instead of
> the whole thread?

That depends which ones you mean (on both ends).

The promise/future from Boost.Thread will block the whole thread, naturally.

The promise/future from Boost.Fiber will block the whole fiber (which is
a type of coroutine, but is different from C++20 coroutines).

Futures and coroutines aren't really a great fit together, since the
former only has a blocking interface while the latter is intended to be
used in an entirely non-blocking fashion.

If you're wanting to work with C++20 style coroutines, probably your
best bet is to use a library such as CppCoro. While this doesn't have a
"future" class per se, it does have the equivalent async version as
"task", and it's possible to do sync waits or wrap it in a future if you
do want to block a thread for some reason.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net