C ++ async uses thread pool when creating for macOS with Xcode?

Using standard development tools and compilers for the platform [1], std::async generate a new OS thread for each background job or use a thread pool or some system based on theft of work tasks?

  • Xcode, Clang / LLVM
+5
source share
2 answers

An application built with a standard platform toolchain (Xcode / Clang) does not use a thread pool. The stack base of a task launched with std::async contains calls to std :: thread and pthread.

Stack trace showing asynchronous operation on a selected OS topic

On exit, each job calls pthread_exit() to kill the thread executing it.

enter image description here

Xcode 8.3.3 also uses the OS thread for every job launched with std::async when creating for iOS (tested on the original target of iPad version 9.7).

enter image description here

+5
source

Currently, the main standard implementation does not use thread pools for std::async . Despite this notion that an implementation can do this, it will be extremely difficult to implement in practice, and I do not foresee it in the near future.

+1
source

Source: https://habr.com/ru/post/1270593/


All Articles