1Parallel::Pipes::App(3pUms)er Contributed Perl DocumentatPiaornallel::Pipes::App(3pm)
2
3
4
6 Parallel::Pipes::App - friendly interface for Parallel::Pipes
7
9 use Parallel::Pipes::App;
10
11 my @result = Parallel::Pipes::App->map(
12 num => 3,
13 work => sub { my $task = shift; $task * 2 },
14 tasks => [1, 2, 3, 4, 5],
15 );
16 # @result is ( 2, 4, 6, 8, 10 )
17
19 Parallel::Pipes::App provides friendly interfaces for Parallel::Pipes.
20
22 Parallel::Pipes::App provides 2 class method:
23
24 map
25 my @result = Parallel::Pipes::App->map(
26 num => $num,
27 work => $work,
28 tasks => \@task,
29 );
30
31 Process @task by $work in $num pre-forked child processes, and get
32 @result. This is almost the same as
33
34 my @result = map { $work->($_) } @task;
35
36 except that $work is executed in a child process, not in the current
37 process.
38
39 run
40 Parallel::Pipes::App->run(
41 num => $num,
42 work => $work,
43 tasks => \@task,
44 before_work => $before_work,
45 after_work => $after_work,
46 );
47
48 "run" is a more generic form of "map". In fact, we can write "map" by
49 using "run":
50
51 my @result;
52 Parallel::Pipes::App->run(
53 num => $num,
54 work => $work,
55 tasks => \@task,
56 before_work => sub {},
57 after_work => sub { push @result, $_[0] },
58 );
59
61 Shoichi Kaji <skaji@cpan.org>
62
64 Copyright 2016 Shoichi Kaji <skaji@cpan.org>
65
66 This library is free software; you can redistribute it and/or modify it
67 under the same terms as Perl itself.
68
69
70
71perl v5.34.0 2022-03-22 Parallel::Pipes::App(3pm)