std::async
Defined in header <future>
|
||
template< class F, class... Args > std::future</* see below */> async( F&& f, Args&&... args ); |
(1) | (since C++11) |
template< class F, class... Args > std::future</* see below */> async( std::launch policy, |
(2) | (since C++11) |
The function template std::async
runs the function f asynchronously (potentially in a separate thread which might be a part of a thread pool) and returns a std::future that will eventually hold the result of that function call.
The return type of std::async
is std::future<V>, where V
is:
typename std::result_of<typename std::decay<F>::type( |
(until C++17) |
std::invoke_result_t<std::decay_t<F>, std::decay_t<Args>...>. |
(since C++17) |
If any of the following conditions is satisfied, the program is ill-formed:
|
(until C++20) |
If any of the following is false, the program is ill-formed:
|
(since C++20) |
The call to std::async
synchronizes with the call to f, and the completion of f is sequenced before making the shared state ready.
Contents |