C++ 当中 std::async 适合用于线程池吗?
- User
C++ 当中 std::async 适合用于线程池吗?
Assistant
std::async本身并不是一个线程池的实现,但它的底层实现可能会利用线程池。理解这一点很重要。我们来分析一下:
std::async的作用:- 异步启动任务:
std::async用于启动一个函数(或者可调用对象),让它(取决于启动策略)在单独的线程中异步执行。
- 异步启动任务:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.