template<typename T>
class OnixS::Threading::SharedFuture< T >
The class template Future provides a mechanism to access the result of asynchronous operations :
- An asynchronous operation (e.g. created via Promise) can provide a Future object to the creator of that asynchronous operation (e.g. via the Promise::getFuture).
- The creator of the asynchronous operation can then use a variety of methods to query, wait for, or extract a value from Future. These methods may block if the asynchronous operation has not yet provided a value.
- When the asynchronous operation is ready to send a result to the creator, it can do so by modifying the shared state (e.g. via the Promise::setValue) that is linked to the creator's Future.
The Future is the synchronization object constructed around the receiving end of the Promise channel. It allows for the separation of the initiation of an operation and the act of waiting for its result.
The Future is copiable and multiple SharedFuture objects may refer to the same shared state.
Unlike the std::future, this implementation has an extended API, allowing you to query the state of SharedFuture. The internal implementation is lock-free; therefore, setting and polling states do not lead to blocking of threads and/or switching of an execution context.
- Note
- An access to the same shared state from multiple threads is safe if each thread does it through its own copy of a SharedFuture object.
- See also
- http://en.cppreference.com/w/cpp/thread/shared_future .
Definition at line 253 of file Future.h.