-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
new-code-exampleNew code exampleNew code example
Description
I would contribute another piece comparing C++ Future Extensions as already available via the Boost Futures implementation vs. native JavaScript promises.
Should be fun discovering their similarities.
E.g. future<X>::then([](future<X>){...}) <=> promise.then(function(x){ ... }))
Good idea?
Edit (August, 1st):
Just to collect ideas here:
| Feature | JS | C++ |
|---|---|---|
| eager execution | new Promise(computation) |
std::async(computation) |
| lazy execution | function task(){ return promise; } |
std::packaged_task(computation) |
| OR combination | Promise.race([]) |
boost::when_any() |
| AND combination | Promise.all([]) |
boost::when_all() |
| consumption | promise.then |
boost::future<>::then |
| success factory | Promise.resolve |
boost::make_ready_future |
| failure factory | Promise.reject |
boost::make_exceptional_future |
Edit (Aug. 21st):
Found a C++ library for the Promises A+ Spec: xhawk18/promise-cpp.
- However evolved wrapping of Boost.Asio needs to be done. Which may be a concern when updating Boost.Asio which natively at least supports
std::future. 😞 - Couldn't yet find code to convert xhawk/promise to/from std::future/boost::future 😞
Metadata
Metadata
Assignees
Labels
new-code-exampleNew code exampleNew code example