How to make boost::thread_group execute a fixed number of parallel threads

后端 未结 4 948
梦如初夏
梦如初夏 2020-12-09 18:59

This is the code to create a thread_group and execute all threads in parallel:

boost::thread_group group;
for (int i = 0; i < 15; ++i)
    group.create_th         


        
4条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-09 19:07

    Another, more efficient solution would be to have each thread callback to the primary thread when they are finished, and the handler on the primary thread could launch a new thread each time. This prevents the repetitive calls to timed_join, as the primary thread won't do anything until the callback is triggered.

提交回复
热议问题