I have some question about behavior of std::async
function with std::launch::async
policy & std::future
object returned from async.
Yes, this is required by the C++ Standard. 30.6.8 [futures.async] paragraph 5, final bullet:
— the associated thread completion synchronizes with (1.10) the return from the first function that successfully detects the ready status of the shared state or with the return from the last function that releases the shared state, whichever happens first.
The destructor of the one and only std:future
satisfies that condition, and so has to wait for the completion of the thread.