std::packaged_task

In this lesson, we will introduce std::packaged_task, which is used to parallelize big computer jobs.

std::packaged_task pack is a wrapper for a callable, in order for it to be invoked asynchronously. By calling pack.get_future(), we get the associated future. Invoking the call operator on a pack (pack()) executes the std::packaged_task and, therefore, executes the callable.

Dealing with std::packaged_task usually consists of four steps:

I. Wrap the work:

Get hands-on with 1400+ tech skills courses.