What is the difference between packaged_task and async

Actually the example you just gave shows the differences if you use a rather long function, such as //! sleeps for one second and returns 1 auto sleep = [](){ std::this_thread::sleep_for(std::chrono::seconds(1)); return 1; }; Packaged task A packaged_task won’t start on it’s own, you have to invoke it: std::packaged_task<int()> task(sleep); auto f = task.get_future(); task(); … Read more