State of IOCP work

Bert Belder H.Belder at student.TUDelft.NL
Wed Dec 8 02:50:46 CET 2010

> -----Oorspronkelijk bericht-----
> Van: at
> [ at]
> Namens Marc Lehmann
> Verzonden: maandag 29 november 2010 13:38
> Aan: Mark Hammond
> CC: libev at
> Onderwerp: Re: State of IOCP work
> On Mon, Nov 29, 2010 at 11:02:36PM +1100, Mark Hammond
> <mhammond at> wrote:
> > Understood - but to be clear, I wasn't suggesting libev performs the
> > IO.  While neither libev or IOCP actually perform IO, they do
> > provide a key mechanism enabling async IO to work in practice -
> > depending on your definition of "work", of course... :)
> No, libev really doesn't enable async I/O nor is it useful to do so.
> when
> you use libev, then doing (event based) synchronous I/O is *far* more
> performant (and *far* easier). using async I/O with I/O events mostly
> defeats the purpose, as it's only adding overhead.
> And while iocps themselves don't perform I/O, you must do I/O for them
> to
> make any sense, so it's academic to say that iocps don't do I/O - they
> can't be used without doing (some form of async) I/O. On some handles
> you
> can get something like an event by doing a 0-size I/O, but that
> work for all handles nor all event types - in practise, you have to
> actually do some (async) I/O with iocps.

Obviously libev doesn't need to do I/O for me.

The problem I run into currently is that select() waits for sockets
only. Sometimes however I do need to wait for a iocp completion packet
or a windows event. Currently the only way to do it is to start a new
thread and wake up the event loop using ev_async_send. It requires a lot
of code every time and pretty much defeats the purpose of libev.

I think it would be possible to implement a backend for windows that
*does* support waiting for event handles and iocps. It could use a wait
function like WaitForMultipleObjectsEx; the stuff select() normally does
would still be possible by creating a socket readiness event using

What would it take, if ever, for you to accept a patch for this?

- Bert

More information about the libev mailing list