possible new timer type - any users?

Marc Lehmann schmorp at schmorp.de
Tue Jun 3 06:47:28 CEST 2008


I had an idea for a new timer type. It would basiclly work like ev_timer
without repeat, with the following differences:

- the actual delay value is constant for a group of such objects (there
  would be two objects: ev_timeout_queue and ev_timeout (naming subject
  to change) - you would specify a constant timeout value to use for all
  timeouts in the queue, but could then put many individual timeouts into
  the queue).

- removing and inserting a timeout into such a queue ("resetting the
  timeout") would be *very* fast O(1), on the order of 5-10 machine
  instructions or so.

The motivation for this very specific timer type would be that, in the real
world, it often is the case that a lot of timers have the same timeout value.

A typical example would be a busy transaction server which would have
activity-timeouts for any socket conenctions, and maybe individual timeouts
per transaction/request.

It is likely that all those time-outs will have the same delay value,
which makes them prime candidates for the proposed new timer.

Using ev_timer involves and O(log n) operation for each insert/remove (in
practise, if one uses ev_timer_again and if the timeout is much longer
than the again-call-interval, as is typical in real-world cases, then
the "n" above is lower than the totral number of timers, but still, the
operation is costly).

Is anybody besides me interested in such a timer? Also, the ev_timeout
name would be fitting, but too simialr to ev_timer, and ev_const_timeout
and ev_const_timeout_queue is way too long - any ideas on a good name?
ev_ctimeout, ev_ctqueue?

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