BGS/Limit.pm

filter: Statementstmt 82.8% 29 / 35 Branchbran 75.0% 3 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 90.0% 9 / 10 Podpod 0.0% 0 / 5 totaltotal 75.9% 41 / 54 CC 5 SCAR 9.7
CC
5
Cov
82%
bgs_wait
6.0
do_job
2.0
bgs_break
2.0
CRAP 2.6
« BGS.pm ↑ Summary BGS/Future.pm »
1 package BGS::Limit;
2  
3 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 4 ▶use Exporter;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 our @ISA = qw(Exporter);
8 4 our @EXPORT = qw(bgs_call bgs_back bgs_wait bgs_break);
9  
10 4 our $VERSION = '0.12';
11  
12 4 ▶use BGS ();
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14  
15 4 my @jobs = ();
16  
17 12 ▶sub bgs_call(&$) { push @jobs, \@_ }
Subroutine bgs_call: called CC=1 SCAR=0.0
Pod undocumented
18 12 ▶sub bgs_back(&) { shift }
Subroutine bgs_back: called CC=1 SCAR=0.0
Pod undocumented
19  
20  
21 11 ▶sub do_job {
Subroutine do_job: called CC=2 SCAR=6.9
Pod undocumented
22 11 ▶ my $job = shift @jobs or return;
Branch: 1 branch
BranchTrueFalseTotal
my $job = shift @jobs or return 9 2 11
23 9 my ($sub, $callback) = @$job;
24 4 ▶ &BGS::bgs_call($sub, sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
25 4 my $r = shift;
26 4 $callback->($r);
27 4 do_job();
28 9 });
29 }
30  
31  
32 4 ▶sub bgs_wait($) {
Subroutine bgs_wait: called CC=4 SCAR=17.9
Pod undocumented
33 4 my ($max) = @_;
34 4 ▶ if ($max) {
Branch: 1 branch
BranchTrueFalseTotal
if ($max) { } 4 0 4
35 4 do_job() foreach 1 .. $max;
36 2 BGS::bgs_wait();
37 } else {
38 0 foreach (@jobs) {
39 0 my ($sub, $callback) = @$_;
40 0 my $r = $sub->();
41 0 $callback->($r);
42 }
43 }
44 }
45  
46  
47 0 ▶sub bgs_break() {
Subroutine bgs_break: not called CC=1 SCAR=6.9
Pod undocumented
48 0 @jobs = ();
49 0 BGS::bgs_break();
50 }
51  
52  
53 4 1;
54  
55  
56 __END__
« BGS.pm ↑ Summary BGS/Future.pm »