boost::io_service api 实现似乎丢失了?
我正在运行 boost 1.43.0 版本,并且看到以下 api(在 asio::io_service 类中):
为了测量性能,返回队列中未完成工作项的数量。
int get_outstanding_work();
int get_ready_work();
我没有找到任何相关的网络文档。虽然我在 io_service.ipp 中看到了它们的实现,但没有实际的实现。我想用它来了解有多少处理程序正在等待处理?
I'm running boost 1.43.0 release, and I see the following api (in asio::io_service class):
For measuring performance, return the number of outstanding work items in the queue.
int get_outstanding_work();
int get_ready_work();
I don't find any web documentation for this.Though I see their implementation in io_service.ipp, but there is no actual implementation. I want to use it for knowing how many handlers are pending?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定此行为是否适用于 io_service 类。
解决方法:
您可能希望在处理程序周围创建一个包装函子,并将其传递给 io_service,而不是直接传递处理程序。
所述包装器将保留对 size_t 变量的引用,并在构造函数上递增该变量,并在 () 运算符上递减该变量。
之后,只需查看 size_t 变量即可检查 io_service 队列中剩余多少个处理程序。
I am not sure this behavior is available for the io_service class.
Workaround:
Instead of directly passing your handlers, you might want to create a wrapper functor around your handlers, and pass that to the io_service.
Said wrapper would keep a reference to a size_t variable and increment that on constructor, and decrement that on the () operator.
After that, just look at the size_t variable to check how many handlers are left in io_service's queue.