The [c++11] std::future
object can be used to retrieve the result of the asynchronous operations or any exceptions it throws.
An asynchronous operation can be created via:
- std::async
- std::packaged_task
- std::promise
Each of the above can provide a std::future object to the creator of that operation.
A std::future object (let name it f) can be used to
- wait for the result: f.wait(), f.wait_for(duration), f.wait_until(time_point)
- retrieve the value (if ready): f.get()
- share its state (std::shared_future): f.share(), f.valid()
More here.