Boost Asio async_wait 处理程序
boost asio deadline_timer
async_wait
函数采用以下形式的处理程序:
void handler(const boost::system::error_code& error)
我如何定义一个采用 const boost::system::error_code& 的处理程序? error 以及一个 int
类型的参数?
boost::asio::deadline_timer t(io_service);
t.async_wait(handler); //I need the async_wait to take in handler which accepts argument boost::system::error_code& error and an int
void handler(int, const boost::system::error_code& error )//extra int argument
谢谢。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 Boost.Bind 为第一个参数:
这里,将使用 0 作为第一个参数来调用处理程序,并且将仅将
error_code
作为第二个参数转发。You could use Boost.Bind to provide a value for the first argument :
Here, the handler will be called with a 0 as its first argument and the
error_code
will simply be forwarded as a second argument.