提升Asio async_wait处理程序

时间:2010-12-13 07:57:10

标签: c++ boost-asio

提升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

感谢。

1 个答案:

答案 0 :(得分:4)

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

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

这里,将使用0作为第一个参数调用处理程序,而error_code将仅作为第二个参数转发。

相关问题