On Mon, Nov 05, 2007 at 02:42:16AM +0100, Marc Lehmann <[EMAIL PROTECTED]>
wrote:
> However, libev has an interface (ev_timer_again) that incrementally
> updates the heap. Also, for repeating timers in general, there is no
> removal/insertion but only an incremental update.
Oh, and sorry for always forgetting stuff... the rationale for supporting
this operation is that I think its pretty important to support timers that
get reset all the time without usually firing (e.g. idle read timeouts on
a normally busy tcp connection).
The other rationale is that its trivial to implement with a heap, because you
already have all the code to do it:
/* incremental timer update in ev_timer_again: */
w->at = mn_now + w->repeat;
downheap (timers, timercnt, w->active - 1);
/* compare with timer removal: */
timers [w->active - 1] = timers [--timercnt];
downheap (timers, timercnt, w->active - 1);
In such a case (updating a timer) the event will simply wander down from
current place in the heap to its new place.
I am not sure wether this can be done with an rb-tree (likely), but I am
sure that I do not want to have to maintain the code that does that :)
(In any case, see the timer benchmark for a good comparison of heap vs.
red-black-tree).
--
The choice of a Deliantra, the free code+content MORPG
-----==- _GNU_ http://www.deliantra.net
----==-- _ generation
---==---(_)__ __ ____ __ Marc Lehmann
--==---/ / _ \/ // /\ \/ / [EMAIL PROTECTED]
-=====/_/_//_/\_,_/ /_/\_\
_______________________________________________
Libevent-users mailing list
[email protected]
http://monkey.org/mailman/listinfo/libevent-users