ExecFlow/Scheduler/SimpleMax.pm

filter: Statementstmt 92.8% 26 / 28 Branchbran 100% 6 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 77.7% 7 / 9 Podpod 0.0% 0 / 7 totaltotal 78.0% 39 / 50 CC 4 SCAR 6.1
CC
4
Cov
94%
schedule_job
3.0
set_max
2.0
set_cnt
2.0
CRAP 1.8
« ExecFlow.pm ↑ Summary ExecFlow/Scheduler.pm »
1 package Event::ExecFlow::Scheduler::SimpleMax;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use base qw ( Event::ExecFlow::Scheduler );
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 8 ▶sub get_max { shift->{max} }
Subroutine get_max: called CC=1 SCAR=0.0
Pod undocumented
7 8 ▶sub get_cnt { shift->{cnt} }
Subroutine get_cnt: called CC=1 SCAR=0.0
Pod undocumented
8  
9 0 ▶sub set_max { shift->{max} = $_[1] }
Subroutine set_max: not called CC=1 SCAR=6.9
Pod undocumented
10 0 ▶sub set_cnt { shift->{cnt} = $_[1] }
Subroutine set_cnt: not called CC=1 SCAR=6.9
Pod undocumented
11  
12 1 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
13 1 my $class = shift;
14 1 my %par = @_;
15 1 my ($max) = $par{'max'};
16  
17 1 return bless {
18 max => $max,
19 cnt => 0,
20 }, $class;
21 }
22  
23 8 ▶sub schedule_job {
Subroutine schedule_job: called CC=3 SCAR=11.0
Pod undocumented
24 8 my $self = shift;
25 8 my ($job) = @_;
26  
27 8 my $state;
28 8 ▶ if ( $self->get_cnt >= $self->get_max ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->get_cnt >= $self->get_max) { } 2 6 8
elsif ($job->get_type ne 'group') { } 5 1 6
29 2 $state = 'sched-blocked';
30 }
31 elsif ( $job->get_type ne 'group' ) {
32 5 ++$self->{cnt};
33 5 $state = 'ok';
34 }
35 else {
36 1 $state = 'ok';
37 }
38
39 8 return $state;
40 }
41  
42 8 ▶sub job_finished {
Subroutine job_finished: called CC=2 SCAR=6.9
Pod undocumented
43 8 my $self = shift;
44 8 my ($job) = @_;
45 8 ▶ --$self->{cnt} if $job->get_type ne 'group';
Branch: 1 branch
BranchTrueFalseTotal
if $job->get_type ne "group" 4 4 8
46 8 1;
47 }
48  
49 1 1;
50  
51 __END__
« ExecFlow.pm ↑ Summary ExecFlow/Scheduler.pm »