ev_timer problem

Marc Lehmann schmorp at schmorp.de
Sat Jul 5 04:27:03 CEST 2008


On Thu, Jul 03, 2008 at 02:47:20PM +0300, vvvua <vvvua at faust.net.ua> wrote:
>  First, i create a timer at 45sec.
>  After each callback, i am trying to set timer on 5 seconds, but timer 
>  waits 45 seconds.

And where do you stop the timer? Quite obviously, taking a timer, handing it
over to some event library and then re-intiialising it's memory block will
at best lead to funny effects, and at worst to crashes.

I don't see in all your snippets where you stop the timer before you
reinitialise it. Note that this would be slow anyway, it is much faster to
just restart it, but stopping, reinitialising and starting works fine as
well.

not stopping it, rowing it over with new data and starting it again will
of course corrupt internal structures.

Without code, there is little to tell however, but I still don't see where
you stop the timer and reinitialise it.

>  If the timer indeed doesn't restart as you want, then you should show us
>  the code that actually resets the timer and restarts it - make sure you
>  stop the timer before modifying it, or, even better, use ev_timer_restart
>  and a suitable restart interval.
> 
>    ev_loop is in different thread. Is this a problem?

No way to tell without all the code (and I'll probably not bother going
through all of it - you are expected to debug your thread problems
yourself). It is fine as long as you follow the rules laid out in the
documentation (search for the "THREADS" section).

Your question is a bit puzzling, however - did you even read the
documentation? If not, why not? If yes, what's unclear about it?

-- 
                The choice of a       Deliantra, the free code+content MORPG
      -----==-     _GNU_              http://www.deliantra.net
      ----==-- _       generation
      ---==---(_)__  __ ____  __      Marc Lehmann
      --==---/ / _ \/ // /\ \/ /      pcg at goof.com
      -=====/_/_//_/\_,_/ /_/\_\



More information about the libev mailing list