PATCH: Integrating libev with other runloops

Marc Lehmann schmorp at
Sun Oct 24 23:55:28 CEST 2010

On Sun, Oct 24, 2010 at 04:31:59PM +0200, Rasmus Andersson <rasmus at> wrote:
> IMHO driving one runloop with another is a "clean" solution and the way to go.

Except it can't be done, so whether it is "clean" or not is academic.

> > In any case, you know there are no active watchers anymore when ev_run
> > returns.
> Ah, so if ev_run returns 0 that means I can mark the libev runloop as
> "unrolled"? And this will include ev_ref/ev_unref's?

No, ev_run doesn't have a return code, but it will return either for
ev_break or when the refcount is zero, both of which is easy to check.

> > This is broken by design - ev_run polls for new events, and if you call
> > ev_run only from time to time you will delay event notification by this
> > amount.
> The implementation in my patch, and thus used in our code, is simply
> copy-pasted from the ev_run code, where AFAIK approximation of next
> invocation is calculated. How would this be solved using the current
> libev (4.0) API in your opinion?

See my previous mail - the only way to do it is using a thread (or a
separate process etc.).

                The choice of a       Deliantra, the free code+content MORPG
      -----==-     _GNU_    
      ----==-- _       generation
      ---==---(_)__  __ ____  __      Marc Lehmann
      --==---/ / _ \/ // /\ \/ /      schmorp at
      -=====/_/_//_/\_,_/ /_/\_\

More information about the libev mailing list