Is there a simple way to determine the number of completion handlers waiting on a particular Boost ASIO strand? I am aware, that that number will only be approximate in a multithreaded environment, as it can always happen, that a completion handler finishes in the nanosecond just after that counter got queried, but before the counter got returned. Or, likewise, other threads could post new work to this strand just after the counter has been queried.
But such an approximate number would already be enough for my application.
I understand, that I could add an std::atomic<std::size_t> variable to my application, which gets incremented, whenever something is posted to the strand, and which is decremented by each completion handler, that gets executed in that strand. But with timers, that sometimes get cancelled, and async sockets, which sometimes get closed unexpectedly, mixed in, I am quite worried, that such application based counters can easily get out of sync. So, is there an easy way to "ask ASIO itself", how much work is waiting on a partiular strand?