std::shared_future (3) - Linux Manuals
std::shared_future: std::shared_future
NAME
std::shared_future - std::shared_future
Synopsis
Defined in header <future>
template< class T > class shared_future; (1) (since C++11)
template< class T > class shared_future<T&>; (2) (since C++11)
template<> class shared_future<void>; (3) (since C++11)
The class template std::shared_future provides a mechanism to access the result of asynchronous operations, similar to std::future, except that multiple threads are allowed to wait for the same shared state. Unlike std::future, which is only moveable (so only one instance can refer to any particular asynchronous result), std::shared_future is copyable and multiple shared future objects may refer to the same shared state.
Access to the same shared state from multiple threads is safe if each thread does it through its own copy of a shared_future object.
Member functions
constructor (public member function)
destructor (public member function)
operator= (public member function)
Getting the result
get (public member function)
State
valid (public member function)
wait (public member function)
wait_for (public member function)
wait_until (public member function)
Example
A shared_future may be used to signal multiple threads simultaneously, similar to std::condition_variable::notify_all()
// Run this code