Boost logo

Boost Users :

Subject: Re: [Boost-users] multithreaded timer?
From: Casimiro, Daniel C CIV NUWC NWPT (daniel.casimiro_at_[hidden])
Date: 2009-03-26 11:16:33

> As far as I could understand, the deadline_timer just runs
> once, i.e., if I would like to use it multiple times, I have
> to instantiate new ones everytime.

That is not true. You can use expires_at or expires_from_now to reschedule an
existing timer. Notice that any pending timeouts will be cancelled when you
reschedule the timer. You have to call async_wait again after you reschedule
the timer.

> It needs to be turned on inside a separate thread, the
> command queue one, when it sends a serial command, and if the
> answer arives before the timer is due, it has to be turned
> off, again inside that separate queue thread, so it doesn't
> hit the "resend".

Use the cancel function to cancel the timer. Your handler function will still
be invoked, but the error code will be "operation cancelled" instead of "not
an error."

> So far I did manage to put it to work, but after a few serial
> commands, some successful and some timed-out, the timer
> associated "service" crashes.

That sounds like a scope problem. The timer object must exist as long as there
are outstanding handlers.


Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at