blib/lib/Event/ExecFlow/Scheduler/SimpleMax.pm untested

filter: Statementstmt 0.0% 0 / 27 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 7 totaltotal 0.0% 0 / 49 CC 4 SCAR 16.4
CC
4
Cov
0%
schedule_job
12.0
job_finished
6.0
get_max
2.0
CRAP 5.2
1 package Event::ExecFlow::Scheduler::SimpleMax;
2  
3 use strict;
4 use base qw ( Event::ExecFlow::Scheduler );
5  
6 sub get_max { shift->{max} }
7 sub get_cnt { shift->{cnt} }
8  
9 sub set_max { shift->{max} = $_[1] }
10 sub set_cnt { shift->{cnt} = $_[1] }
11  
12 sub new {
13 my $class = shift;
14 my %par = @_;
15 my ($max) = $par{'max'};
16  
17 return bless {
18 max => $max,
19 cnt => 0,
20 }, $class;
21 }
22  
23 sub schedule_job {
24 my $self = shift;
25 my ($job) = @_;
26  
27 my $state;
28 if ( $self->get_cnt >= $self->get_max ) {
29 $state = 'sched-blocked';
30 }
31 elsif ( $job->get_type ne 'group' ) {
32 ++$self->{cnt};
33 $state = 'ok';
34 }
35 else {
36 $state = 'ok';
37 }
38
39 return $state;
40 }
41  
42 sub job_finished {
43 my $self = shift;
44 my ($job) = @_;
45 --$self->{cnt} if $job->get_type ne 'group';
46 1;
47 }
48  
49 1;
50  
51 __END__