[zeromq-dev] zloop timers
ph at imatix.com
Wed May 25 07:16:30 CEST 2011
On Tue, May 24, 2011 at 5:32 PM, Kim Lester <kim at dfusion.com.au> wrote:
> If we insert the timers into the timer list in order of delay then
> a) we move calculations outside core zloop
> a) we don't need to iterate over list looking for shortest delay, just take first item (note second timer equal first I suppose but we can test that when the first expires)
> b) save on calculating "when" for all bar first item in list.
Hmm, you'll then need to reorder the list each time a timer expires,
since it's not just the delay but the starting time. So a timer with a
1000ms delay could go off before one with a 100ms delay.
Ideally you would keep timers in order of next expiry, and have a good
algorithm for reordering the list. I believe the Linux kernel does
this with timers, perhaps there is code to reuse from that.
More information about the zeromq-dev