Store a value in the asynchronous result associated with *this
without making that result ready until the current
thread exits.
void promise<void>::set_value_at_thread_exit(); void promise<R&>::set_value_at_thread_exit(R& r); void promise<R>::set_value_at_thread_exit(R const& r); void promise<R>::set_value_at_thread_exit(R&& r);
- Preconditions:
*thishas an associated asynchronous result.- Effects:
Store
rin the asynchronous result associated with*thisifResultTypeis notvoid. Mark the asynchronous result as having a stored value. Schedule the associated asynchronous result to be made ready when the current thread exits.- Postconditions:
The asynchronous result associated with
*thishas a stored value, but is not ready until the current thread exits. Threads blocked waiting for the asynchronous result will be unblocked when the current thread exits.- Throws:
An exception of type
std::future_errorwith an error code ofstd::future_errc::promise_already_satisfiedif the asynchronous result already has a stored value or exception. Any exceptions thrown by the copy-constructor or move-constructor ofr.- Synchronization:
Multiple concurrent calls to
set_value(),set_value_at_thread_exit(),set_exception()andset_exception_at_thread_exit()are serialized. The completion of the thread that made a successful call toset_value_at_thread_exit()happens-before a call tostd::future<ResultType>::get()orstd::shared_future<ResultType>::get()which retrieves the exception stored.
Header
#include <future>