ev_io and message queues

Marc Lehmann schmorp at schmorp.de
Fri Mar 27 22:38:47 CET 2009

On Fri, Mar 27, 2009 at 08:55:34PM +0100, Joachim Nilsson <troglobit at gmail.com> wrote:
> connecting an ev_io watcher to the message queue identifier, which is
> rumored to be a standard file descriptor in Linux. No luck so far.

I never heard that this should be the case, and would be very surprised if
this would suddenly be so.

> 1) Is this even possible?

I don't think so, those are not, to my knowledge, file descriptors.

> Can I use any POSIX message queue primitives with ev_io

I don't think so, although I would be less surprised if those were
actually fd's.

> or should I attempt a redesign using standard file descriptors or pipes?

For an event-based system this is likely the only way to do it.

> 2) Does anyone have any other neat idea how to integrate ev_io with
> message passing?

Use another thread to blockingly wait, then wake up your event loop with
ev_async, then process the received messages.

Not neat, imho, but workable. If you already have threads, this seems
reasonable, though.

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

More information about the libev mailing list