Given an object that provides a `run()` method, you can create a `Parallel::Tiny` fork manager object that will execute that method several times.
my $obj = My::Handler->new();
my $forker = Parallel::Tiny->new(
handler => $obj,
workers => 4,
worker_total => 32,
);
$forker->run();
In the above example we will execute the `run()` method for a `My::Handler` object 4 workers at a time, until 32 total workers have completed/died.
# METHODS
- new()
Returns a new `Parallel::Tiny` fork manager.
Takes the following arguments as a hash or hashref:
{
handler => $handler, # provide an object with a run() method, this will be your worker (required)
reap_timeout => $reap_timeout, # how long to wait in between reaping children (default ".1")
subname => $subname, # a method name to execute for the $handler (default "run")
workers => $workers, # the number of workers that can run simultaneously (default 1)
worker_total => $worker_total, # the total number of times to run before stopping (default 1)
}
For instance, you could run 100 workers, 4 workers at a time: