繁体   English   中英

提升Asio async_wait处理程序

[英]Boost Asio async_wait handler

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

谢谢。

您可以使用Boost.Bind为第一个参数提供值:

t.async_wait(boost::bind(handler, 0, _1));

这里,将使用0作为其第一个参数调用处理程序,并将error_code简单地作为第二个参数转发。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM