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,
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 (required) 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) reap_timeout - the number of seconds to wait between runs of waitpid() to reap children (default .1) kill_all - When the parent gets TERM, kill all child processes immediately. (default 0)
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!
- run()
-
Start spooling jobs according to the configuration.
- waitqueue()
-
Blocks until a job slot is available.