【发布时间】:2012-10-11 07:24:34
【问题描述】:
获得std::future 的一种方法是通过std::async:
int foo()
{
return 42;
}
...
std::future<int> x = std::async(foo);
在这个例子中,x 的异步状态的存储是如何分配的,哪个线程(如果涉及多个线程)负责执行分配?此外,std::async 的客户是否可以控制分配?
对于上下文,我看到std::promise 的one of the constructors 可能会收到分配器,但我不清楚是否可以在std::async 级别自定义std::future 的分配。
【问题讨论】:
标签: c++ asynchronous c++11 future c++-standard-library