Erratic timers

2008-11-28 Thread Graham Leggett

Hi all,

I am struggling getting a simple timer to work with libev. What I want 
to achieve is a timer that gets called immediately, and then repeating 
every 2 seconds after that.


The docs describe various complex timer options, but miss the simplest 
version, and I am struggling for some reason.


If I do the following:

  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.


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

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


Regards,
Graham
--


smime.p7s
Description: S/MIME Cryptographic Signature
___
libev mailing list
libev@lists.schmorp.de
http://lists.schmorp.de/cgi-bin/mailman/listinfo/libev

Re: Erratic timers

2008-11-29 Thread Marc Lehmann
On Sat, Nov 29, 2008 at 02:45:24AM +0200, Graham Leggett <[EMAIL PROTECTED]> 
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
  --==---/ / _ \/ // /\ \/ /  [EMAIL PROTECTED]
  -=/_/_//_/\_,_/ /_/\_\

___
libev mailing list
libev@lists.schmorp.de
http://lists.schmorp.de/cgi-bin/mailman/listinfo/libev