[Asio] problem with deadline_timer

This is a small program using deadline_timer with expiration time 1 millisecond. http://snipt.org/nKm When I run it over and over it will evantually stuck lie this: http://img39.imageshack.us/img39/1292/handh.jpg and I don't know why. The io_service.run() is started in another thread. The main thread is waiting for pressing 'any key', the I call post() method to cancel() the timer. But sometimes as you can see on the screenshot, cancel() is invoked, but the timer continues to run. It seems that run() method doesn't invoke the timer handler with boost::asio::error::operation_aborted error. I've noticed this effect will be encouraged by high CPU usage. Vista 64bit, VC++ 2008 Express, Boost 1.40.0 Why this is happening?

The timer event is in the ASIO queue when your "stop" handler is called. Check the return value of "timer.cancel()" to determine if the timer was actually cancelled. If "timer.cancel()" returns zero, the timer already fired. ~Dan
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of moffet Sent: Monday, September 28, 2009 3:43 To: boost-users@lists.boost.org Subject: [Boost-users] [Asio] problem with deadline_timer
This is a small program using deadline_timer with expiration time 1 millisecond. http://snipt.org/nKm When I run it over and over it will evantually stuck lie this: http://img39.imageshack.us/img39/1292/handh.jpg and I don't know why.
The io_service.run() is started in another thread. The main thread is waiting for pressing 'any key', the I call post() method to cancel() the timer. But sometimes as you can see on the screenshot, cancel() is invoked, but the timer continues to run. It seems that run() method doesn't invoke the timer handler with boost::asio::error::operation_aborted error. I've noticed this effect will be encouraged by high CPU usage.
Vista 64bit, VC++ 2008 Express, Boost 1.40.0
Why this is happening?
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
Casimiro, Daniel C CIV NUWC NWPT
-
moffet