Long-running / blocking operations in boost asio handlers

前端 未结 2 621
你的背包
你的背包 2021-02-03 15:22

Current Situation

I implemented a TCP server using boost.asio which currently uses a single io_service object on which I call the run method f

2条回答
  •  不要未来只要你来
    2021-02-03 16:04

    We have same long-running tasks in our server (a legacy protocol with storages). So our server is running 200 threads to avoid blocking service (yes, 200 threads is running io_service::run). Its not too great thing, but works well for now.

    The only problem we had is asio::strand which uses so-called "implementations" which gets locked when hadler is currently called. Solved this via increase this strands butckets and "deattaching" task via io_service::post without strand wrap.

    Some tasks may run seconds or even minutes and this does work without issues at the moment.

提交回复
热议问题