Fwd: need some detail about ev_async.

Marc Lehmann schmorp at schmorp.de
Tue Nov 22 12:01:30 CET 2011

On Mon, Nov 21, 2011 at 10:11:40PM +0100, Zsbán Ambrus <ambrus at math.bme.hu> wrote:
> believe), eventfd is not supported.  I think this implementation can
> block if the pipe is full, which could happen eg. if you are calling
> ev_async_send many times (even on different ev_async watchers).  In

the pipe is non-blocking, so it will not block even in this very unlikely

> recent (yet to be released, libev-4.09) versions of libev, this write
> to the pipe is guarded by some flag construction, which might have the

even in released versions this write is guarded by a flag, and usually not
done more than once per event-loop iteration.

> know if it does.  I guess schmorp can answer this.  Frankly, I don't
> know much about SMP and don't even understand whether that new flag
> construction must work reliably (that is, can't cause the event loop
> to miss an async send event).

the old flag implementation worked because it was just an optimisation.
the new dual-flag needs memory barriers (well, not on existing x86 cpus,
but libev provides the barriers just in case) for correctness.

                The choice of a       Deliantra, the free code+content MORPG
      -----==-     _GNU_              http://www.deliantra.net
      ----==-- _       generation
      ---==---(_)__  __ ____  __      Marc Lehmann
      --==---/ / _ \/ // /\ \/ /      schmorp at schmorp.de
      -=====/_/_//_/\_,_/ /_/\_\

More information about the libev mailing list