标准函数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/