Parallel::Pipes::App − friendly interface for Parallel::Pipes
use
Parallel::Pipes::App;
my @result = Parallel::Pipes::App−>map(
num => 3,
work => sub { my $task = shift; $task * 2 },
tasks => [1, 2, 3, 4, 5],
);
# @result is ( 2, 4, 6, 8, 10 )
Parallel::Pipes::App provides friendly interfaces for Parallel::Pipes.
Parallel::Pipes::App provides 2 class method:
my @result =
Parallel::Pipes::App−>map(
num => $num,
work => $work,
tasks => \@task,
);
Process @task by $work in $num pre−forked child processes, and get @result. This is almost the same as
my @result = map { $work−>($_) } @task;
except that $work is executed in a child process, not in the current process.
Parallel::Pipes::App−>run(
num => $num,
work => $work,
tasks => \@task,
before_work => $before_work,
after_work => $after_work,
);
"run" is a more generic form of "map". In fact, we can write "map" by using "run":
my @result;
Parallel::Pipes::App−>run(
num => $num,
work => $work,
tasks => \@task,
before_work => sub {},
after_work => sub { push @result, $_[0] },
);
Shoichi Kaji <[email protected]>
Copyright 2016 Shoichi Kaji <[email protected]>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.