Boost Users :
Subject: Re: [Boost-users] [asio] need help with timer crash please
From: Igor R (boost.lists_at_[hidden])
Date: 2009-03-27 05:36:33
> Thanks for the reply. Â However, I've confirmed that the
> boost::asio::deadline_timer object still exists.
The timer object exists, but what about the objects which are accessed
from the handler? Can you post some code snippet?
> In examples I've found for repeating timers, that the timer is re-scheduled
> within the handler itself. Â In my case, the timer is re-scheduled sometime after
> the handler has run. Â I wonder if a timer cannot be re-used this way?
The timer can be used in any way, until you don't try to access it
simultaneously from multiple threads.
> One additional bit of information is that the timer is scheduled for the very
first time by the main process, before the worker thread enters
io_service::run(). Is there any problem with scheduling a timer with one thread
and then re-scheduling it with another?
If you mean something like this:
thread t(&io_service::run, &io);
then it's ok, because there's no race conditions here: when you access
the timer from the main thread, the timer is not running.
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