line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
## |
2
|
|
|
|
|
|
|
## Load Average Constraint |
3
|
|
|
|
|
|
|
## Author: Vipul Ved Prakash . |
4
|
|
|
|
|
|
|
## $Id: Freq.pm,v 1.6 2005/04/26 07:31:08 hackworth Exp $ |
5
|
|
|
|
|
|
|
## |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
package Schedule::Chronic::Constraint::Freq; |
8
|
1
|
|
|
1
|
|
359
|
use Schedule::Chronic::Base; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
20
|
|
9
|
1
|
|
|
1
|
|
4
|
use base qw(Schedule::Chronic::Base); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
333
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# NOTE: This module overloads the concept of wait to store the number of |
12
|
|
|
|
|
|
|
# seconds left before execution. Don't let this confuse you, |
13
|
|
|
|
|
|
|
# specially if you are looking at this as a an example for your |
14
|
|
|
|
|
|
|
# constraint module. |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub new { |
18
|
0
|
|
|
0
|
0
|
|
return bless {}, shift; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub init { |
23
|
|
|
|
|
|
|
|
24
|
0
|
|
|
0
|
0
|
|
my ($self, $schedule, $task, $logger, $seconds) = @_; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# @args can be: |
27
|
|
|
|
|
|
|
# 86400 |
28
|
|
|
|
|
|
|
# 86400, Force |
29
|
|
|
|
|
|
|
# Force is not implemented |
30
|
|
|
|
|
|
|
|
31
|
0
|
|
|
|
|
|
$$self{schedule} = $schedule; |
32
|
0
|
|
|
|
|
|
$$self{task} = $task; |
33
|
0
|
|
|
|
|
|
$$self{logger} = $logger; |
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
$$self{seconds} = $seconds; |
36
|
0
|
|
|
|
|
|
$$self{wait} = 0; |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
return $self; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub met { |
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
46
|
|
|
|
|
|
|
|
47
|
0
|
0
|
|
|
|
|
return 1 if $$self{task}{last_ran} == 0; |
48
|
0
|
|
|
|
|
|
$$self{wait} = $$self{task}{last_ran} - (time() - $$self{seconds}); |
49
|
0
|
|
|
|
|
|
$self->debug(" freq wait = $$self{wait} seconds"); |
50
|
0
|
0
|
|
|
|
|
return 1 if ($$self{wait} < 0); |
51
|
0
|
|
|
|
|
|
return 0; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub wait { |
57
|
|
|
|
|
|
|
|
58
|
0
|
|
|
0
|
0
|
|
return $_[0]->{wait}; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |
63
|
|
|
|
|
|
|
|