m_timer.async_wait(boost::bind(&IntervalEvent::handler, this));
should be: m_timer.async_wait(boost::bind(&IntervalEvent::handler, this, _1)); or: m_timer.async_wait(boost::bind(&IntervalEvent::handler, this, boost::asio::placeholders::error));
void handler(boost::system::error_code& error)
should be: void handler(cosnt boost::system::error_code& error)
Further to that, I am wondering, in principle should I cancel the deadline_timer on the destructor of the IntervalEvent class? Does the io_service class know when any of the deadline_timers that is being registered goes out of scope?
On destruction, the timer cancels itself anyway. By the way, you access the timers both from main() and from another thread - which is illegal, since the asio objects are not thread-safe (except for io_service).