I have a two-layer object structure where the contained object has a deadline_timer and the outer object has the handler function, as:
class Internal
{
asio::deadline_timer t;
public:
void QueueTick(void (*handler)(boost::system::error_code const&))
{
t.expires_from_now(posix_time::millisec(250));
t.async_wait(handler);
}
};
class ForClients
{
Internal I;
void OnTick(boost::system::error_code const&) { /*...*/ }
void Init()
{
I.QueueTick(boost::bind(&cdevXcite::OnTick, this, _1));
}
};
The QueueTick()
call is failing to compile in MSVS 2008 with "cannot convert parameter 1 from 'boost::_bi::bind_t' to 'void (__cdecl *)(const boost::system::error_code &)'".
If I make the timer member public and make a direct call to I.t.async_wait()
with the same argument, it succeeds. Clearly, the handler's signature is more special than what I've used in the QueueTick
declaration; however, I can't find a symbol that defines it and I don't know how to interpret the metaprogramming going on inside the basic_deadline_timer<>
template.