From just::thread
documentation:
If policy is
std::launch::async
then runsINVOKE(fff,xyz...)
on its own thread. The returnedstd::future
will become ready when this thread is complete, and will hold either the return value or exception thrown by the function invocation. The destructor of the last future object associated with the asynchronous state of the returnedstd::future
shall block until the future is ready.
In
std::async(std::launch::async, foo, arg1, arg2);
The returned future is not assigned anywhere and its destructor blocks until foo
finishes.