line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
24
|
|
|
24
|
|
86
|
use strict; |
|
24
|
|
|
|
|
25
|
|
|
24
|
|
|
|
|
687
|
|
2
|
|
|
|
|
|
|
package Event::timer; |
3
|
24
|
|
|
24
|
|
77
|
use Carp; |
|
24
|
|
|
|
|
22
|
|
|
24
|
|
|
|
|
1006
|
|
4
|
24
|
|
|
24
|
|
78
|
use base 'Event::Watcher'; |
|
24
|
|
|
|
|
22
|
|
|
24
|
|
|
|
|
1299
|
|
5
|
24
|
|
|
24
|
|
84
|
use vars qw(@ATTRIBUTE); |
|
24
|
|
|
|
|
26
|
|
|
24
|
|
|
|
|
6029
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
@ATTRIBUTE = qw(at hard interval); |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
'Event::Watcher'->register; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
|
|
|
|
|
|
# lock %Event::; |
13
|
46
|
|
|
46
|
0
|
49
|
my $class = shift; |
14
|
46
|
|
|
|
|
98
|
my %arg = @_; |
15
|
46
|
|
100
|
|
|
1202
|
my $o = allocate($class, delete $arg{attach_to} || {}); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# deprecated |
18
|
45
|
|
|
|
|
78
|
for (qw(at after interval repeat)) { |
19
|
180
|
50
|
|
|
|
301
|
if (exists $arg{"e_$_"}) { |
20
|
0
|
|
|
|
|
0
|
carp "'e_$_' is renamed to '$_'"; |
21
|
0
|
|
|
|
|
0
|
$arg{$_} = delete $arg{"e_$_"}; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
45
|
|
|
|
|
63
|
my $has_at = exists $arg{at}; |
26
|
45
|
|
|
|
|
46
|
my $has_after = exists $arg{after}; |
27
|
|
|
|
|
|
|
|
28
|
45
|
50
|
66
|
|
|
101
|
croak "'after' and 'at' are mutually exclusive" |
29
|
|
|
|
|
|
|
if $has_at && $has_after; |
30
|
|
|
|
|
|
|
|
31
|
45
|
100
|
|
|
|
97
|
if ($has_after) { |
|
|
100
|
|
|
|
|
|
32
|
39
|
|
|
|
|
42
|
my $after = delete $arg{after}; |
33
|
39
|
|
|
|
|
178
|
$o->at(Event::time() + $after); |
34
|
39
|
|
|
|
|
37
|
$has_at=1; |
35
|
39
|
100
|
|
|
|
176
|
$o->interval($after) if !exists $arg{interval}; |
36
|
|
|
|
|
|
|
} elsif ($has_at) { |
37
|
1
|
|
|
|
|
3
|
$o->at(delete $arg{at}); |
38
|
|
|
|
|
|
|
} |
39
|
45
|
100
|
|
|
|
81
|
if (exists $arg{interval}) { |
40
|
3
|
|
|
|
|
5
|
my $i = delete $arg{interval}; |
41
|
3
|
50
|
|
|
|
14
|
$o->at(Event::time() + (ref $i? $$i : $i)) unless $has_at; |
|
|
100
|
|
|
|
|
|
42
|
3
|
|
|
|
|
7
|
$o->interval($i); |
43
|
3
|
50
|
|
|
|
19
|
$o->repeat(1) unless exists $arg{repeat}; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
45
|
|
|
|
|
238
|
$o->init(\%arg); |
47
|
43
|
|
|
|
|
107
|
$o; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
1; |