Use std::mutex for a thread pool managed by boost::asio

前端 未结 4 1382
执笔经年
执笔经年 2021-01-03 08:36

Somehow a followup of this question. I am only wondering if it is ok to use a std::mutex in functions handeled by a boost::asio:io_service? Usage o

4条回答
  •  别那么骄傲
    2021-01-03 08:54

    Mutex inside completion handler can block thread execution. In that case you need more io_service threads than boost::thread::hardware_concurrency() to load CPU for 100%. It increases thread switching overhead.

提交回复
热议问题