ProcessPool/Pipeline.pm

filter: Statementstmt 100% 34 / 34 Branchbran 100% 2 / 2 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 9 / 9 Podpod 100% 3 / 3 totaltotal 92.4% 49 / 53 SCAR 11.0
CC
3
Cov
95%
pipeline
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 3.0
« ProcessPool/Task.pm ↑ Summary
1 package AnyEvent::ProcessPool::Pipeline;
2 # ABSTRACT: A simplified, straightforward way to parallelize tasks
3 1 $AnyEvent::ProcessPool::Pipeline::VERSION = '0.06';
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use AnyEvent::ProcessPool;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Try::Catch;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 ▶use parent 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 our @EXPORT = qw(pipeline in out);
12  
13 sub pipeline (%) {
14 1 ▶ my %param = @_;
Subroutine pipeline: called CC=3 SCAR=11.0
Pod documented
15 1 my $in = delete $param{in};
16 1 my $out = delete $param{out};
17 1 ▶ my $pool = delete $param{pool} || AnyEvent::ProcessPool->new(%param);
Condition33%1/3
delete $param{'pool'} || 'AnyEvent::ProcessPool'->new(%param)
l!l&&r!l&&!r
010
MC/DC0%0/2
delete $param{'pool'} || 'AnyEvent::ProcessPool'->new(%param)
delete $param{'pool'} 'AnyEvent::ProcessPool'->new(%param)
Truth table33%1/3
A || B
A= delete $param{'pool'}B= 'AnyEvent::ProcessPool'->new(%param)
ABresult
1X1
011
000
18 1 my $count = 0;
19  
20 1 my %pending;
21 1 ▶ while (my @task = $in->()) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@task) = &$in()) 10 1 11
22 10 my $cv = $pool->async(@task);
23 10 $pending{$cv} = $cv;
24 10 ▶ $cv->cb(sub{ ++$count; $out->(shift) });
Subroutine __ANON__: called CC=1 SCAR=0.0
25 }
26  
27 1 $pool->join; # wait for all tasks to complete
28  
29 1 return $count;
30 }
31  
32 1 ▶sub in (&) { return (in => $_[0]) }
Subroutine in: called CC=1 SCAR=0.0
Pod documented
33 1 ▶sub out (&) { return (out => $_[0]) }
Subroutine out: called CC=1 SCAR=0.0
Pod documented
34  
35 1 1;
36  
37 __END__
« ProcessPool/Task.pm ↑ Summary