Created
May 15, 2013 13:46
-
-
Save kimmel/5584103 to your computer and use it in GitHub Desktop.
Parallel::ForkManager example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use v5.16; | |
use warnings; | |
use autodie qw( :all ); | |
use utf8::all; | |
use Parallel::ForkManager; | |
my $process_count = 12; | |
sub run_list { | |
my $pm = shift; | |
my $log = shift; | |
my $entries = shift; | |
foreach my $b ( @{$entries} ) { | |
print {$log} " processing: $b\n"; | |
my $pid = $pm->start and next; | |
#... | |
$pm->finish; | |
} | |
return; | |
} | |
... | |
my $pm = Parallel::ForkManager->new($process_count); | |
run_list($pm, $log, \@entires); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment