Invoke the task associated with a std::packaged_task instance, and
store the return value or exception in the associated asynchronous result
without making the associated asynchronous result ready
until thread exit.
void make_ready_at_thread_exit(ArgTypes... args);
- Preconditions:
*thishas an associated task.- Effects:
Invoke the associated task
funcas-ifINVOKE(func,args...). If the invocation returns normally, store the return value in the asynchronous result associated with*this. If the invocation returns with an exception, store the exception in the asynchronous result associated with*this. Schedule the associated asynchronous state to be made ready when the current thread exits.- Postconditions:
The asynchronous result associated with
*thishas a stored value or exception, 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. An exception of typestd::future_errorwith an error code ofstd::future_errc::no_stateif*thishas no associated asynchronous state.- Synchronization:
The completion of the thread that made a successful call to
make_ready_at_thread_exit()happens-before a call tostd::future<ResultType>::get()orstd::shared_future<ResultType>::get()which retrieves the value or exception stored.
Header
#include <future>