Boost logo

Boost :

Subject: Re: [boost] Promise/A+ like javascript in cpp
From: Gavin Lambert (gavinl_at_[hidden])
Date: 2018-07-27 00:50:03


On 26/07/2018 00:15, hawk x wrote:
> Javascript Promise creates a task chain to help develop asynchronized
> application with single thread.
>
> I did not find a good implement of this kind of "Promise" in c++

std::future::then was proposed for C++17, but didn't make it in. Boost
does support it, however, as does an STL that implements the Concurrency
TS (as std::experimental::future::then).

https://www.boost.org/doc/libs/1_67_0/doc/html/thread/synchronization.html#thread.synchronization.futures.then

Additionally, Boost.Asio supports using coroutines for implementing
asynchronous tasks, which are even better than a then-chain and read
even more like plain synchronous code.

https://www.boost.org/doc/libs/1_67_0/doc/html/boost_asio/overview/core/spawn.html

https://www.boost.org/doc/libs/1_67_0/doc/html/boost_asio/example/cpp11/spawn/echo_server.cpp

Currently coroutines are a pure library feature (supported by
Boost.Context and Boost.Coroutine), but they are expected to be
supported directly by C++20 compilers, and by C++17 compilers that
implement the Coroutine TS (VS 2017 already supports co_await, for example).

https://www.boost.org/doc/libs/1_67_0/doc/html/boost_asio/overview/core/coroutines_ts.html

https://www.boost.org/doc/libs/1_67_0/doc/html/boost_asio/examples/cpp17_examples.html


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