Does standard C++11 guarantee that std::async(std::launch::async, func) launches func in separate thread? Does standard C++11 guarantee that std::async(std::launch::async, func) launches func in separate thread? multithreading multithreading

Does standard C++11 guarantee that std::async(std::launch::async, func) launches func in separate thread?


The two key statements here are:

as if in a new thread of execution represented by a thread object

The thread object is stored in the shared state and affects the behavior of any asynchronous return objects that reference that state.

"As if" means it must behave exactly as if it had created a std::thread object for this function. Which means that all side effects of the creation of a std::thread must also happen.

That being said, if you combine launch::async with launch::deferred, then the implementation decides whether to launch a new thread or defer it to an existing one. So it's only launch::async alone that requires a new thread.