Abu*_*akr 25 c++ boost boost-thread c++11
boost::thread_groupC++ 11中有什么类似的东西吗?
我只是试图将我的程序从使用移植boost:thread到C++ 11线程,并且无法找到任何等效的东西.
Ant*_*ams 28
不,boost::thread_group在C++ 11中没有任何直接的等价物.std::vector<std::thread>如果你想要的只是一个容器,你可以使用.然后,您可以使用新for语法或std::for_each调用join()每个元素,或者其他任何元素.
thread_group 没有进入C++ 11和C++ 14标准.
但解决方法很简单:
std::vector<std::thread> grp;
// to create threads
grp.emplace_back(functor); // pass in the argument of std::thread()
void join_all() {
for (auto& thread : grp)
if (thread.joinable())
thread.join();
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9366 次 |
| 最近记录: |