std::packaged_task
wraps any Callable
so that it can run asynchronously. It allows you to extract a std::future
out of it which will be set when the task is executed. This allows you to transfer the task to another thread and wait on the future, enabling asynchronous execution.
template< class F >
explicit packaged_task( F&& f );
It has a member function get_future
through which we get the std::future
associated with the result. The function can only be called once.