If I run std::async using the std::launch::async rule, should I not run every asynchronous task in a new thread?
The specification requires that the asynchronous operation be performed "as in a new thread of execution" (C ++ 11 Β§30.6.8 / 11). The important words here are: as if.
An already existing workflow can be reused if and only if the behavior is the same as if a new thread were created. This means, for example, that variables with the storage class thread_local must be reset between asynchronous operations performed on the same thread.
It is not necessary that the thread identifier be reset, because the thread identifier only uniquely identifies the stream during its operation. If the thread terminates, another thread may be started with the first thread identifier.
Is there any major job theft or something like that?
This is implementation specific. The implementation of the C ++ 11 threading library for Visual C ++ 2012 is built on top of the Concurrency Runtime (ConcRT) , which includes a job scheduler.
source share