line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
24
|
|
|
24
|
|
158
|
use strict; |
|
24
|
|
|
|
|
50
|
|
|
24
|
|
|
|
|
782
|
|
2
|
|
|
|
|
|
|
package Event::timer; |
3
|
24
|
|
|
24
|
|
122
|
use Carp; |
|
24
|
|
|
|
|
48
|
|
|
24
|
|
|
|
|
1165
|
|
4
|
24
|
|
|
24
|
|
126
|
use base 'Event::Watcher'; |
|
24
|
|
|
|
|
1696
|
|
|
24
|
|
|
|
|
7464
|
|
5
|
24
|
|
|
24
|
|
158
|
use vars qw(@ATTRIBUTE); |
|
24
|
|
|
|
|
40
|
|
|
24
|
|
|
|
|
16506
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
@ATTRIBUTE = qw(at hard interval); |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
'Event::Watcher'->register; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
|
|
|
|
|
|
# lock %Event::; |
13
|
46
|
|
|
46
|
0
|
82
|
my $class = shift; |
14
|
46
|
|
|
|
|
158
|
my %arg = @_; |
15
|
46
|
|
100
|
|
|
1527
|
my $o = allocate($class, delete $arg{attach_to} || {}); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# deprecated |
18
|
45
|
|
|
|
|
136
|
for (qw(at after interval repeat)) { |
19
|
180
|
50
|
|
|
|
399
|
if (exists $arg{"e_$_"}) { |
20
|
0
|
|
|
|
|
0
|
carp "'e_$_' is renamed to '$_'"; |
21
|
0
|
|
|
|
|
0
|
$arg{$_} = delete $arg{"e_$_"}; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
45
|
|
|
|
|
93
|
my $has_at = exists $arg{at}; |
26
|
45
|
|
|
|
|
68
|
my $has_after = exists $arg{after}; |
27
|
|
|
|
|
|
|
|
28
|
45
|
50
|
66
|
|
|
117
|
croak "'after' and 'at' are mutually exclusive" |
29
|
|
|
|
|
|
|
if $has_at && $has_after; |
30
|
|
|
|
|
|
|
|
31
|
45
|
100
|
|
|
|
111
|
if ($has_after) { |
|
|
100
|
|
|
|
|
|
32
|
39
|
|
|
|
|
69
|
my $after = delete $arg{after}; |
33
|
39
|
|
|
|
|
209
|
$o->at(Event::time() + $after); |
34
|
39
|
|
|
|
|
65
|
$has_at=1; |
35
|
39
|
100
|
|
|
|
153
|
$o->interval($after) if !exists $arg{interval}; |
36
|
|
|
|
|
|
|
} elsif ($has_at) { |
37
|
1
|
|
|
|
|
4
|
$o->at(delete $arg{at}); |
38
|
|
|
|
|
|
|
} |
39
|
45
|
100
|
|
|
|
103
|
if (exists $arg{interval}) { |
40
|
3
|
|
|
|
|
8
|
my $i = delete $arg{interval}; |
41
|
3
|
50
|
|
|
|
16
|
$o->at(Event::time() + (ref $i? $$i : $i)) unless $has_at; |
|
|
100
|
|
|
|
|
|
42
|
3
|
|
|
|
|
12
|
$o->interval($i); |
43
|
3
|
50
|
|
|
|
18
|
$o->repeat(1) unless exists $arg{repeat}; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
45
|
|
|
|
|
212
|
$o->init(\%arg); |
47
|
43
|
|
|
|
|
149
|
$o; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
1; |