lib/Schedule/Chronic/Constraint/Inactivity.pm

filter: Statementstmt 43.3% 13 / 30 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 44.4% 4 / 9 Podpod 0.0% 0 / 5 totaltotal 30.9% 17 / 55 CC 5 SCAR 16.5
CC
5
Cov
33%
met
12.0
init
6.0
wait
6.0
CRAP 5.2
« lib/Schedule/Chronic/Constraint/Freq.pm ↑ Summary blib/lib/Schedule/Chronic/Constraint/InXs.pm »
1 ##
2 ## Detect System Inactivity
3 ## Author: Vipul Ved Prakash <mail@vipul.net>.
4 ## $Id: Inactivity.pm,v 1.3 2004/07/15 21:11:08 hackworth Exp $
5 ##
6  
7 package Schedule::Chronic::Constraint::Inactivity;
8 1 ▶use Schedule::Chronic::Base;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Schedule::Chronic::Constraint::Loadavg;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Schedule::Chronic::Constraint::DiskIO;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use base qw(Schedule::Chronic::Base);
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13  
14 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
15  
16 0 my ($class) = @_;
17  
18 0 return bless {
19  
20 loadavg => new Schedule::Chronic::Constraint::Loadavg ($debug),
21 diskio => new Schedule::Chronic::Constraint::DiskIO ($debug),
22  
23 # This class doesn't have its own timer. Timers are maintained by
24 # DiskIO and Loadavg.
25  
26 }, shift
27  
28 }
29  
30  
31 0 ▶sub init {
Subroutine init: not called CC=2 SCAR=17.9
Pod undocumented
32  
33 0 my ($self, $schedule, $task, $logger, $active) = @_;
34 0 ▶ return unless ref $self;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 0 0 0
35
36 0 $$self{loadavg}->init($schedule, $task, $logger, $active);
37 0 $$self{diskio}->init($schedule, $task, $logger, $active);
38 0 $$self{logger} = $logger;
39  
40 0 return $self;
41  
42 }
43  
44  
45 0 ▶sub met {
Subroutine met: not called CC=3 SCAR=24.8
Pod undocumented
46  
47 0 my ($self) = @_;
48  
49 0 ▶ if ($self->{loadavg}->met() && $self->{diskio}->met()) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'loadavg'}->met and $self->{'diskio'}->met) { } 0 0 0
Condition0%0/3
$self->{"loadavg"}->met and $self->{"diskio"}->met
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"loadavg"}->met and $self->{"diskio"}->met
$self->{"loadavg"}->met $self->{"diskio"}->met
Truth table0%0/3
A and B
A= $self->{"loadavg"}->metB= $self->{"diskio"}->met
ABresult
0X0
100
111
50 0 return 1;
51 } else {
52 0 return 0;
53 }
54  
55 }
56  
57  
58 0 ▶sub state {
Subroutine state: not called CC=1 SCAR=6.9
Pod undocumented
59  
60 # This is a "Container Constraint" that doesn't have a state of its
61 # own, so we return undef. This is an indication to the poller that
62 # the constraint doesn't have a state.
63  
64 0 return;
65  
66 }
67  
68  
69 0 ▶sub wait {
Subroutine wait: not called CC=2 SCAR=17.9
Pod undocumented
70  
71 0 my $self = shift;
72 0 my $loadavg_wait = $self->{loadavg}->wait();
73 0 my $diskio_wait = $self->{diskio}->wait();
74  
75 0 ▶ return $loadavg_wait > $diskio_wait ? $loadavg_wait : $diskio_wait;
Branch: 1 branch
BranchTrueFalseTotal
$loadavg_wait > $diskio_wait ? : 0 0 0
76  
77 }
78  
79  
80 1 1;
81  
« lib/Schedule/Chronic/Constraint/Freq.pm ↑ Summary blib/lib/Schedule/Chronic/Constraint/InXs.pm »