[timers] - triggering at the same time

Neeraj Rai rneeraj at yahoo.com
Sat Dec 17 04:15:57 CET 2011


1. Sorry, I am not that familiar with libev. 
  a) Is there a libev function I can call to check if there is already a 
  timer at a given offset ?
  Currently I am not storing my timers sorted by time.
  b) if not, what would be the best data structure for that?

2. I was thinking of assigning running seqno, so large number of pri.
  Maybe this option is not such a good idea.

4. the prepare callback sounds promising but I can't figure out from the
  example how it would be used.

  When I init/start a timer, do I also init/start a prepare ?
  Are all the timers at the same time bunched in same preppare callback ?
    

--- On Fri, 12/16/11, Marc Lehmann <schmorp at schmorp.de> wrote:


From: Marc Lehmann <schmorp at schmorp.de>
Subject: Re: [timers] - triggering at the same time
To: "Neeraj Rai" <rneeraj at yahoo.com>
Cc: libev at lists.schmorp.de
Date: Friday, December 16, 2011, 6:31 PM


On Thu, Dec 15, 2011 at 06:41:31PM -0800, Neeraj Rai <rneeraj at yahoo.com> wrote:
> 1. if I can find out that there is already a timer at the time I am adding, I can fudge the 
> timer to have timeout+.0001 to make it trigger later. Is this possible ?

With the corresponding data structure you can do that.

> 2. can I set priority on the timers. Because then I could maintain running seqno and inc
> it on each call to denote the later ones trigger later.

If the limited number of priorities are enough for this, then that would
be the simplest solution.

> 3. I need to maintain my timers in sorted timed buckets (probably similar to what libev 
> does internally) and detect the time collision before adding the timer.

Thats basically option 1).

You could also collect all the timers that were invoked with their timeout
value and then execute them in the order you want in a prepare callback.

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




More information about the libev mailing list