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.
A shared_future
may be used to signal multiple threads simultaneously, similar to std::condition_variable::notify_all().
Possible output:
Thread 1 received the signal 0.072 ms after start Thread 2 received the signal 0.041 ms after start[edit] See also runs a function asynchronously (potentially in a new thread) and returns a std::future that will hold the result
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4