Iteration over registered handlers

Marc Lehmann schmorp at
Mon Nov 30 17:24:36 CET 2020

On Wed, Nov 25, 2020 at 02:43:21PM +0100, Rick van Rein <rick at> wrote:
> I love libev.  The complex to-do list in my mind quickly clears up when
> I add it to a project.  It's lovely to have this global database under a
> single pointer that pops out relevant data alongside interesting events.
> For cleanup purposes, I'd like to iterate over registered event handlers
> after I've broken out of a loop.  I cannot find a macro or function, is
> that not part of the API?

It's not part of the API because it would require libev to add overhead to
track watchers.

If you need this functionality, you can add it easily on top of libev.

Doing it yourself also ensures that you are only doing it to your own
watchers, and not watchers by others (e.g. libev internal ones). Even if
you could iterate over all watchers in libev, how would you decide which
watchers are your own without outside knowledge?

> [I'm cautious about hacking it in, because of the obvious fine balance
> of platform knowledge built into the code.]

It's probably just as simple and easier to maintain wrappers around the
start/stop functions you use.

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

More information about the libev mailing list