Freigeben über


packaged_task::operator() Operator

Calls the callable object that's stored in the associated asynchronous state, atomically stores the returned value, and sets the state to ready.

void operator()(ArgTypes... args);

Remarks

If the packaged_task object doesn't have an associated asynchronous state, this method throws a future_error that has an error code of no_state.

If this method or make_ready_at_thread_exit has already been called for a packaged_task object that has the same associated asynchronous state, the method throws a future_error that has an error code of promise_already_satisfied.

Otherwise, this operator calls INVOKE(fn, args..., Ty), where fn is the callable object that's stored in the associated asynchronous state. Any returned value is stored atomically as the returned result of the associated asynchronous state, and the state is set to ready. As a result, any threads that are blocked on the associated asynchronous state become unblocked.

Requirements

Header: future

Namespace: std

See Also

Reference

packaged_task Class

<future>