std::packaged_task<R(Args...)>::operator()

From cppreference.com
 
 
Thread support library
Threads
(C++11)
this_thread namespace
(C++11)
(C++11)
(C++11)
Mutual exclusion
(C++11)
Generic lock management
(C++11)
(C++11)
(C++11)
(C++11)(C++11)(C++11)
(C++11)
(C++11)
Condition variables
(C++11)
Futures
(C++11)
(C++11)
(C++11)
(C++11)
 
 
void operator()( ArgTypes... args );
(since C++11)

Calls the stored task with args as the arguments. The return value of the task or any exceptions thrown are stored in the shared state. The shared state is made ready and any threads waiting for this are unblocked.

Parameters

args - the parameters to pass on invocation of the stored task

Return value

(none)

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.

Notes

A successful call to operator() synchronizes with a call to any member function of a std::future or std::shared_future that share their shared state with *this.

(until C++14)

No additional synchronization guarantees other than what's already provided by shared state.

(since C++14)

Example

See also

executes the function ensuring that the result is ready only once the current thread exits
(public member function)