Documentation Home >> Headers >> <future> Header >> std::atomic_future >> std::atomic_future<>::get Member function

If the associated state contains a deferred function from a call to std::async then invoke that function and return the result. Otherwise, wait until the asynchronous result associated with an instance of std::atomic_future is ready, and then return the stored value or throw the stored exception.

void atomic_future<void>::get() const;
R& atomic_future<R&>::get() const;
R const& atomic_future<R>::get() const;

Preconditions:

this->valid() would return true.

Effects:

Calls to get() and wait() from multiple threads on std::atomic_future instances that share the same associated state are serialized. If the associated state contains a deferred function then the first call to get() or wait() invokes the deferred function and stores the returned value or thrown exception as the asynchronous result.

Block until the asynchronous result associated with *this is ready. If the associated state contains a stored exception then throw the stored exception, otherwise return the stored value.

Returns:

If ResultType is void then return normally. If ResultType is R& for some type R then return the stored reference. Otherwise, return a const reference to the stored value.

Throws:

The stored exception, if any.

Header

#include <future>

See Also