Event-polling after a fork

Marc Lehmann schmorp at schmorp.de
Fri Feb 28 19:48:08 CET 2020

On Thu, Feb 27, 2020 at 07:03:16AM -0500, Felipe Gasper <felipe at felipegasper.com> wrote:
> Once I took a step back, I realized that because AE’s internal references to the watchers are weakened, AnyEvent->reset() would only remove those references and not fire any DESTROY handlers. So yeah, it would serve no purpose.

I think you are looking at the wrong code - AnyEvent itself does not keep
any references, weak or not, to watchers.

However, even if it only stored weak references, that wouldn't stop it
from resetting weatchers, if it really wanted and it would be useful.

> (With Mojo the reset() method works because Mojo::IOLoop stores normal references.)

Since you never really defined what "works" means, it's hard to assess
the validity of that statement, buit it certainly doesn't work for
any practical use case, because reste resets all watchers, those that
need resetting, and those that don't, so it would break otherwise
correctly-written programs. In other words, no, it doesn't "work", by

I strongly think you are hunting an XY problem here - a "reset" is not a
solution to your problems with fork.

                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 anyevent mailing list