boost:: ¿grupo de subprocesos en C++11?
¿Hay algo parecido a boost::thread_group
en C++11?
Solo estoy tratando de portar mi programa de usar boost:thread
a subprocesos de C++11 y no pude encontrar nada equivalente.
23
2 answers
No, no hay nada directamente equivalente a boost::thread_group
en C++11. Podría usar un std::vector<std::thread>
si todo lo que desea es un contenedor. Luego puede usar la nueva sintaxis for
o std::for_each
para llamar a join()
en cada elemento, o lo que sea.
25
Author: Anthony Williams,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2012-03-27 17:07:23
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2012-03-27 17:07:23
thread_group
no llegó a los estándares C++11 y C++14.
Pero una solución es simple:
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();
}
6
Author: rustyx,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-03-23 11:07:32
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-03-23 11:07:32