AnyEvent::Fork::Early - avoid having to exec another perl interpreter
# only usable in the main program, and must be called # as early as possible #!/usr/bin/perl use AnyEvent::Fork::Early; # now you can do other stuff
AnyEvent::Fork normally spawns a new perl process by executing the perl binary. It does this because it is the only way to get a "clean state", as the program using it might have loaded modules that are not fork friendly (event loops, X11 interfaces and so on).
However, in some cases, there is no external perl interpreter to execute, for example, when you use App::Staticperl or PAR::Packer to embed perl into another program, and that program runs on another system without perl installed.
And anyway, forking would still be more efficient, if it were possible.
And, as you hopefully guessed, this module makes this possible - it must be run by the main program (i.e. to cannot be used in a module), and as early as possible. How early? Well, early enough so that any other modules can still be loaded and used, that is, before modules such as AnyEvent or Gtk2 are being initialised.
use'ing the module, the process is forked, and the resulting process is used as a template process for
new_exec, so everything should just work out.
Please resist the temptation to delay
useing this module to preload more modules that could be useful for your own purposes, see AnyEvent::Fork::Template for that.
Marc Lehmann <firstname.lastname@example.org> http://home.schmorp.de/