Are multiple ASIO io_services a good thing?

后端 未结 3 1552
深忆病人
深忆病人 2021-02-01 19:19

I\'ve begun using Boost.ASIO for some simple network programming, my understanding of the library is not a great deal, so please bear with me and my newbie question.

At

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-01 20:03

    We use multiple io_service's because some of the components in our application need to run all their worker threads at certain fixed priorities, different for each component. Thus each component is given its own io_service, and each component has its own pool of threads executing run().

    Other designs I could think of would be if a different number of threads in the pool is required for each IO, or, more relevant to your case, is if the pool cannot be shared because, for example, if your network IO can take out every thread and leave your serial IO waiting.

提交回复
热议问题