-
-
08 Apr 2017 23:09:08 UTC
- Distribution: Parallel-Tiny
- Module version: 1
- Source (raw)
- Browse (raw)
- Changes
- How to Contribute
- Issues (0)
- Testers (128 / 0 / 0)
- Kwalitee
Bus factor: 0- 88.36% Coverage
- License: perl_5
- Activity
24 month- Tools
- Download (10.06KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
NAME
Parallel::Tiny
DESCRIPTION
Provides a simple, no frills fork manager.
SYNOPSIS
Given an object that provides a
run()
method, you can create aParallel::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 aMy::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:
my $forker = Parallel::Tiny->new( handler => $obj, workers => 4, worker_total => 100, );
infinite
can be provided for the$worker_total
but you will need to manage stopping the fork manager elsewhere.If the parent is sent
SIGTERM
it will wait to reap all currently executing children before finishing.If the parent is killed, children will receive
SIGHUP
, which you will need to deal with in your$handler
. - run()
-
Start running a number of parallel workers equal to
$workers
, until a number of workers equal to$worker_total
have been completed.
Module Install Instructions
To install Parallel::Tiny, copy and paste the appropriate command in to your terminal.
cpanm Parallel::Tiny
perl -MCPAN -e shell install Parallel::Tiny
For more information on module installation, please visit the detailed CPAN module installation guide.