std::packaged_task<R(Args...)>::make_ready_at_thread_exit - cppreference.com (original) (raw)
| void make_ready_at_thread_exit( ArgTypes... args ); | | (since C++11) | | ------------------------------------------------------- | | ------------- |
Calls the stored task as if by INVOKE(f, args...), where f is the stored task. The return value of the task or any exception thrown by it is stored in the shared state of *this.
The shared state is only made ready after the current thread exits and all objects of thread-local storage duration are destroyed.
[edit] Parameters
| args | - | the parameters to pass on invocation of the stored task |
|---|
[edit] Return value
(none)
[edit] Exceptions
std::future_error on the following error conditions:
- The stored task has already been invoked. The error category is set to
promise_already_satisfied. - *this has no shared state. The error category is set to no_state.
[edit] Example
Output:
task: executed worker: future is not ready yet worker: exit main: worker finished main: future is ready