Erratic timers

Marc Lehmann schmorp at schmorp.de
Sat Nov 29 11:37:26 CET 2008


On Sat, Nov 29, 2008 at 02:45:24AM +0200, Graham Leggett <minfrin at sharp.fm> wrote:
> to achieve is a timer that gets called immediately, and then repeating  
> every 2 seconds after that.
>
>   ev_timer_init(&msg->timer.timer, watch_timed_message_cb, 0., 2.);
>   ev_timer_start(msg->c->s->e->loop, &msg->timer.timer);
>
> I expect the timer to fire in 0. seconds, and then start repeating every  
> 2. seconds after that.

That's what it will do.

> Instead the timer fires off once immediately, and then nothing.

Most probably you stop the timer, or exit the program or the event loop,
or something else.

> Can anyone confirm whether there are further steps that I need to take  
> before this will work?

There are no further steps necessary - most likely the further steps are
the problem. If you post an example that compiles I can probbaly tell you
what's wrong.

-- 
                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