c++ - 是否有使用线程池的 std::async 实现?

标签 c++ multithreading concurrency threadpool

标准函数std::async :

The template function async runs the function f asynchronously (potentially in a separate thread which may be part of a thread pool) and returns a std::future that will eventually hold the result of that function call.

有两个启动策略std::launch::async and std::launch::deferred .在我的编译器 (GCC 6.2) 标准库实现中,第一个总是创建一个新线程,第二个在调用线程上执行惰性计算。默认使用 std::launch::deferred

当指定 std::launch::async 时,是否有一些使用大小等于可用硬件线程的线程池的实现,以避免在 std::async 时创建两个多线程 是用在递归算法中吗?

最佳答案

Microsoft 的编译器和它随 Visual Studio 一起提供的 C++ 运行时。

关于c++ - 是否有使用线程池的 std::async 实现?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40806894/

相关文章:

等参数的 C++ 函数特化

python - 尝试了解 WSGI 的阻塞本质

c++ - 编译错误 c++ "was not declared in this scope" "expected type specifier"等

c++ - 在 C++ 中连接到 sql?

java - 多线程不同步访问Hashmap

C++11内存模型: why can't compiler move statements across load() operations during optimization?

java - 按顺序并发运行 Runnable

java - 适合 Java 事件监听器的集合类

c++ - Qt 和 QDateTime 比较

java - 事件派发线程如何工作?