Reputation: 9970
Using the standard development tools and compilers for the platform[1], does std::async
spawn a new OS thread for each background job or does it use a thread pool or some system based on work stealing task queues?
Upvotes: 5
Views: 716
Reputation: 9970
An application built with the standard toolchain for the platform (Xcode/Clang) does not use a thread pool. The base of the stack of a task launched with std::async
contains std::thread and pthread calls.
On exit, each job calls pthread_exit()
to kill the thread running it.
Xcode 8.3.3 also uses an OS thread per job launched with std::async
when building for iOS (Tested on original iPad Pro 9.7" target).
Upvotes: 5
Reputation: 62603
No major standard implementation currently uses thread pools for std::async
. Despite that notion that implementation could do this, this would be extremely hard in practice for implementations, and I do not foresee it in any near future.
Upvotes: 1