[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [Libevent-users] persistent 0 second timer events



On Mon, Aug 26, 2013 at 5:23 PM, J. Scott Dorr <j.scott.dorr@xxxxxxxxx> wrote:
> I often use 0 second timer events to put something onto the event queue in a
> friendly manner (ie. allow other items that were already there to be
> processed, and get to my 'new work' when it's fair to).
>
> Trying to set up a persistent 0 second timer doesn't work, though:
>
> event_set(evq, -1, EV_PERSIST, my_callback, udata);
> if (udata->evbase) {
>
> event_base_set(udata->evbase, evq);
>
> }
> udata->tv.tv_sec = 0;
> udata->tv.tv_usec = 0;
> evtimer_add(evq, &(udata->tv));
>
>
> If tv.tv_sec or tv.tv_usec is any positive value, everything works as I
> expect, I get a persistent timer event.  However, if they are both 0, the
> timer event fires once, but never again.
>
> Is this a known issue?

Hm. What would be the semantics of a 0-second persistent timer?  You'd
want the event backend to never block, and you'd want the 0-second
timer's callback to run on every single iteration of the event loop?

Looking at event_persist_closure() in event.c, it looks as though it
doesn't distinguish a 0-second timeout from "no timeout".  Perhaps it
should.  Anybody want to write a (tested) patch?

-- 
Nick
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.