boost:asio thread pool implementation for occasionally synchronized tasks

前端 未结 3 1768
执念已碎
执念已碎 2021-02-04 11:21

I have a \"main\" function that performs many small, independent tasks each once per time step. However, after each time step, I must wait for all of the tasks to complete befor

3条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-04 11:41

    may be you can use boost::barrier as follow:

    void thread_proc( boost::barrier& b ) {
        while( true ) {
            if( !ioservice.run_one() ) break; // io_service stopped
            b.wait();
        }
    }
    

提交回复
热议问题