boost::asio::io_service occupied queue lengths for timers and posts

六眼飞鱼酱① 提交于 2019-12-03 05:58:51

You cannot get statistics about the io_service queue without modifying the asio library directly. As you have noted, the container is private. The size of the queue is really not terribly important anyhow, since the performance or throughput depends on the completion handlers. What I've done in the past to solve something similar is to measure the time required to post a trivial handler to the io_service

void
Status::impl()
{
    const boost::posix_time::ptime start = boost::posix_time::microsec_clock::local_time();
    _io_service.post(
        boost::bind(
            &Status::loadHandler,
            this,
            start
        )
    );
}

void
Status::loadHandler(
    const boost::posix_time::ptime& start,
    )
{
    // calculate duration spent in reactor queue
    const boost::posix_time::ptime end = boost::posix_time::microsec_clock::local_time();
    const boost::posix_time::time_duration load = end - start;
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!