|
Boost Users : |
Subject: Re: [Boost-users] [asio] deadline_timer callback is not called
From: Igor R (boost.lists_at_[hidden])
Date: 2009-10-14 12:35:59
> Mmmm...so maybe, in the other project, it worked because I called timers
into the asio::serial_port::async_read_some callback that should be inside
the io_service thread! Isn't it?
asio::deadline_timer is not thread-safe, so you're not allowed to access it
from multiple threads. Since it's being processed by the io_service from
within its thread, you have to post any timer method to the io_service (as
far as I understand).
> Yes, the setTimer is called, but the timer callback not!
You call expires_from_now and async_wait from setTimer(), and the handler is
not called? Well, that's weird.
Ensure you pass reasonable time duration. Try to use the overload that
returns an error:
boost::system::error_code er;
expires_from_now(seconds(1), er);
What does it return in "er"?
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net