I'm fairly new to boost::asio, but I'm working on a project that has already existed for a few years and uses asio extensively. My current assignment is to add periodic metrics about various things the system is doing. One of the metrics is to observe how deep the boost::asio::io_service work queues and timer queues become at an arbitrary period of runtime. So I need to be able to ask a boost:asio::io_service object how many things it has in its queues.
To illustrate what I'm asking, consider the following:
boost::asio::io_service asio_service;
asio_service.post( boost::bind( do_work, "eat" ) );
asio_service.post( boost::bind( do_work, "drink" ) );
asio_service.post( boost::bind( do_work, "and be merry!" ) );
std::cout << "There are " << asio_service.XXXX()
<< "things in the post() queue and "
<< asio_service.YYYY() << " timers"
Is there a way with boost asio to get equivalent functionality to what my "XXXX()" and "YYYY()" calls are expressing?
I looked at the asio timer queue code and saw that the queue is really just a vector and a list, but both are private. Since they are private, I cannot inherit to gain access, and I don't want to have to inherit or write some kind of odd-ball visitor pattern to wrap things up for this one pair of metrics: direct access to these counts would be ideal; special versions of boost that I hack-up to give me access would not be ideal: I'm looking for a way to do this that already exists in boost. Hopefully I'm not the first to ask for this.