Environment:
Windows XP
Boost 1.40
Problem: Canceling an asio::deadline_timer doesn't pass an
operation_aborted value to the timer handler.
---------------
From the async_wait doc:
For each call to async_wait(), the supplied handler will be called
exactly once. The handler will be called when:
* The timer has expired.
* The timer was cancelled, in which case the handler is passed the error
code boost::asio::error::operation_aborted.
---------------
When I call my Restart() function (which calls the cancel() function) my
TimerHandler() receives an err value of 0. When the timer is allowed to
expire, the TimerHandler doesn't get called at all.
Thoughts?
- Bruce
Here's the relevant code:
boost::asio::io_service mIOService;
boost::asio::deadline_timer mTimer(mIOService,
boost::posix_time::seconds(3))
inline void TimerHandler(const boost::system::error_code& err)
{
cout << err;
if (err && err != boost::asio::error::operation_aborted)
{
cout << endl << "Watchdog elapsed" << endl;
}
}
void Start() {
mTimer.async_wait(TimerHandler);
mIOService.run();
}
// Cancels and restarts the watchdog timer - prevents a timeout
void Restart() {
mTimer.cancel();
mTimer.async_wait(TimerHandler);
mIOService.reset();
mIOService.run();
}
_______________________________________________
Boost-users mailing list
Boost...@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users
--
You received this message because you are subscribed to the Google Groups "BOOST Archives" group.
To post to this group, send email to
boost...@googlegroups.com.
To unsubscribe from this group, send email to
boost-list+...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/boost-list?hl=en.