alternate approach to timer inaccuracy due to cached times

Brandon Black blblack at
Fri Oct 14 16:05:45 CEST 2011

On Fri, Oct 14, 2011 at 6:34 AM, Denis Bilenko <denis.bilenko at> wrote:
> Shaun, your patch does not seem to work for me with the above program
> - the callback is not called at all if the patch is applied.

The primary issue with the idea behind his patch (I don't know about
the implementation) is that it guarantees some timeouts will not fire
until much later than expected.  By basing all timer starts on the end
stamp of loop event processing rather than the beginning, the new
minimum delay for a timeout is now the event processing delay + the
specified timeout.  So for example, in his original scenario (500ms
timeouts, and 500ms to process a batch of events), with his patched
approach some of his timeouts would effectively become 1000ms
timeouts.  It's basically automatically applying the workaround of
"expand the timeout to be large enough that the event processing delay
doesn't matter so much", at the expense of making timeouts much more
inexact and unpredictable in the senses that they're exact and
predictable today.

More information about the libev mailing list