Showing content from https://cplusplus.com/packaged_task::operator() below:
public member function
<future>
std::packaged_task::operator()
void operator()(Args... args);
Call stored task
Calls the stored task, forwarding args as its arguments.
- If the call to the stored task completes successfully, the value it returns (if any) is stored in the shared state.
- If the call to the stored task throws an exception, the exception is caught and also stored in the shared state.
In both cases, the shared state is made ready (which unblocks any threads currently waiting for it).
The shared state can be accessed by calling get on a future object returned by a previous call to member get_future.
The stored task is generally specified on construction. The effects of calling it depend on its type:
- If the stored task is a function pointer or a function object, it is called forwarding the arguments to the call.
- If the stored task is a pointer to a non-static member function, it is called using the first argument as the object on which the member is called (this may either be an object, a reference, or a pointer to it), and the remaining arguments are forwarded as arguments for the member function.
- If it is a pointer to a non-static data member, it should be called with a single argument, and the function stores in the shared state a reference to that member of its argument (the argument may either be an object, a reference, or a pointer to it).
Parameters
-
args...
-
Arguments for the call.
If the type of the stored task is a member pointer, the first argument shall be an object for which that member is defined (or a reference, or a pointer to it).
Args... are the packaged_task template parameters, which represent the types of the arguments for the stored task .
Return value none.
The return value of the stored task (if any) is stored in the shared state.
Data races The packaged_task is modified.
The shared state is modified as an atomic operation (causing no data races).
Exception safetyBasic guarantee: if an exception is thrown, the packaged_task is in a valid state.
This member function throws an exception on the following conditions:
This member function also throws if any copy or movement of the arguments throws and -depending on the library implementation- may also throw to report other situations.
See also
-
packaged_task::make_ready_at_thread_exit
-
Call stored task and make ready at thread exit (public member function)
-
packaged_task::get_future
-
Get future (public member function)
-
future::get
-
Get value (public member function)
RetroSearch is an open source project built by @garambo
| Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4