std::packaged_task<R(Args...)>::operator()
From cppreference.com
< cpp | thread | packaged task
C++
Concurrency support library
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
std::packaged_task
| Member functions | ||||
| Getting the result | ||||
| Execution | ||||
packaged_task::operator() | ||||
| Non-member functions | ||||
| Helper classes | ||||
|
(until C++17)
|
||||
| Deduction guides(C++17) |
|
void operator(
)
( ArgTypes... args
)
;
|
(since C++11) | |
Calls the stored task as if by INVOKE<R>(f, args...), where f
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.
Example
| This section is incomplete Reason: no example |
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 with a call to any member function of a std::future or std::shared_future that share their shared state with *this |
no additional synchronization guarantees other than what is already provided by shared state |
See also
| executes the function ensuring that the result is ready only once the current thread exits (public member function) |