std::packaged_task<R(Args...)>::operator() - cppreference.com (original) (raw)
| void operator()( 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 exceptions thrown are stored in the shared state. The shared state is made ready and any threads waiting for this are unblocked.
[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
[edit] Defect reports
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
| DR | Applied to | Behavior as published | Correct behavior |
|---|---|---|---|
| LWG 2142 | C++11 | a successful call to operator() synchronized witha call to any member function of a std::future orstd::shared_future that share their shared state with *this | no additional synchronizationguarantees other than what isalready provided by shared state |