July 2017
Intermediate to advanced
244 pages
6h 33m
English
A shared_future is just like a regular future object, but can be copied, which allows multiple threads to read its results.
Creating a shared_future is similar to a regular future.
std::promise<void> promise1; std::shared_future<void> sFuture(promise1.get_future());
The biggest difference is that the regular future is passed to its constructor.
After this, all threads which have access to the future object can wait for it, and obtain its value. This can also be used to signal threads in a way similar to condition variables.
Read now
Unlock full access