NAME
Parallel::Tiny
DESCRIPTION
Provides a very simple, no frills fork manager.
SYNOPSIS
my $obj = My::Handler->new();
my $forker = Parallel::Tiny->new(
handler => $obj,
subname => 'start', # My::Handler must implement start()
workers => 4,
worker_total => 'infinite',
);
$forker->run();
METHODS
- new()
-
Returns a new Parallel::Tiny fork manager.
takes arguments as a hash or hashref with the following arguments:
handler - an object you provide which has a run() method (unless you define "subname") (required) reap_timeout - the number of seconds to wait between runs of waitpid() to reap children (default .1) subname - the name of the sub you want to invoke on child spawn (default 'run') workers - the number of simoltaneous forked processes you want to allow at one time (default 1) worker_total - the total number of processes that you want to run (default 1)
You can for instance, say that you want to run 100 proccesses, but only 4 at a time like this:
my $forker = Parallel::Tiny->new( handler => $obj, workers => 4, worker_total => 100, );
If you want you can provide 'infinite' for worker_total. If you do this, you're responsible for stopping the fork manager!
Signals: ---
If the parent is sent SIGTERM, the parent will wait to reap all children.
If the parent is killed before its children finish, children are configured to receive HUP.
- run()
-
Start spooling jobs according to the configuration.