Copying a watcher

Marc Lehmann schmorp at schmorp.de
Wed Jan 5 22:41:01 CET 2011


On Wed, Jan 05, 2011 at 05:30:36PM +0100, Gabriel Kerneis <kerneis at pps.jussieu.fr> wrote:
> is it safe to copy a (potentially active or pending) watcher, destroy
> the original one and use only the copy afterwards?

Well, think about it - if you would try to do that, how would you ever
stop the watcher, as you just destroyed the unique ID (it's address).

> (Or maybe my question should be: does libev retain pointers to
> active/pending watchers?)

Sometimes it does, sometimes it doesn't, but this is a separate question,
even for watchers where libev does not retain pointers you are not allowed
to destroy them, move them etc., without telling libev about it.

> I might have missed it but did not find anything about it in the manual.

It's actually mentioned quite a few times, for example in "ANATOMY OF
A WATCHER" (which everybody should read), in the description of the
ev_xxx_stop function, ev_is_active, ev_is_pending, it's mentioned in
detail multiple times in "WATCHER STATES", and that's when i stopped
looking.

I am honestly a bit surprised at how you can miss it, if you really tried
to read the documentation :)

-- 
                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