| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
24
|
|
|
24
|
|
78
|
use strict; |
|
|
24
|
|
|
|
|
26
|
|
|
|
24
|
|
|
|
|
676
|
|
|
2
|
|
|
|
|
|
|
package Event::Watcher; |
|
3
|
24
|
|
|
24
|
|
74
|
use base 'Exporter'; |
|
|
24
|
|
|
|
|
23
|
|
|
|
24
|
|
|
|
|
1302
|
|
|
4
|
24
|
|
|
24
|
|
85
|
use Carp; |
|
|
24
|
|
|
|
|
28
|
|
|
|
24
|
|
|
|
|
1107
|
|
|
5
|
24
|
|
|
24
|
|
103
|
use vars qw(@EXPORT_OK @ATTRIBUTE); |
|
|
24
|
|
|
|
|
22
|
|
|
|
24
|
|
|
|
|
1594
|
|
|
6
|
|
|
|
|
|
|
@EXPORT_OK = qw(ACTIVE SUSPEND R W E T); |
|
7
|
|
|
|
|
|
|
@ATTRIBUTE = qw(cb cbtime desc debug prio reentrant repeat max_cb_tm); |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub register { |
|
10
|
24
|
|
|
24
|
|
85
|
no strict 'refs'; |
|
|
24
|
|
|
|
|
19
|
|
|
|
24
|
|
|
|
|
7259
|
|
|
11
|
122
|
|
|
122
|
0
|
190
|
my $package = caller; |
|
12
|
|
|
|
|
|
|
|
|
13
|
122
|
|
|
|
|
114
|
my $name = $package; |
|
14
|
122
|
|
|
|
|
718
|
$name =~ s/^.*:://; |
|
15
|
|
|
|
|
|
|
|
|
16
|
122
|
|
|
|
|
118
|
my $sub = \&{"$package\::new"}; |
|
|
122
|
|
|
|
|
302
|
|
|
17
|
122
|
50
|
|
|
|
281
|
die "can't find $package\::new" |
|
18
|
|
|
|
|
|
|
if !$sub; |
|
19
|
122
|
|
|
|
|
455
|
*{"Event::".$name} = sub { |
|
20
|
4731
|
|
|
4731
|
|
1963218
|
shift; |
|
21
|
4731
|
|
|
|
|
8889
|
$sub->("Event::".$name, @_); |
|
22
|
122
|
|
|
|
|
382
|
}; |
|
23
|
|
|
|
|
|
|
|
|
24
|
122
|
50
|
|
|
|
432
|
&Event::add_hooks if @_; |
|
25
|
|
|
|
|
|
|
} |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my $warn_noise = 10; |
|
28
|
|
|
|
|
|
|
sub init { |
|
29
|
4730
|
50
|
|
4730
|
0
|
6620
|
croak "Event::Watcher::init wants 2 args" if @_ != 2; |
|
30
|
4730
|
|
|
|
|
3720
|
my ($o, $arg) = @_; |
|
31
|
|
|
|
|
|
|
|
|
32
|
4730
|
|
|
|
|
7887
|
for my $k (keys %$arg) { |
|
33
|
23354
|
50
|
|
|
|
29064
|
if ($k =~ s/^e_//) { |
|
34
|
0
|
0
|
|
|
|
0
|
Carp::cluck "'e_$k' is renamed to '$k'" |
|
35
|
|
|
|
|
|
|
if --$warn_noise >= 0; |
|
36
|
0
|
|
|
|
|
0
|
$arg->{$k} = delete $arg->{"e_$k"}; |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
|
|
40
|
4730
|
100
|
|
|
|
7395
|
if (!exists $arg->{desc}) { |
|
41
|
|
|
|
|
|
|
# try to find caller but cope with optimized-away frames & etc |
|
42
|
4708
|
|
|
|
|
5437
|
for my $up (1..4) { |
|
43
|
9416
|
|
|
|
|
33166
|
my @fr = caller $up; |
|
44
|
9416
|
100
|
66
|
|
|
36022
|
next if !@fr || $fr[0] =~ m/^Event\b/; |
|
45
|
4708
|
|
|
|
|
5497
|
my ($file,$line) = @fr[1,2]; |
|
46
|
4708
|
|
|
|
|
7935
|
$file =~ s,^.*/,,; |
|
47
|
4708
|
|
|
|
|
10957
|
$o->desc("?? $file:$line"); |
|
48
|
4708
|
|
|
|
|
6913
|
last; |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# set up prio |
|
53
|
|
|
|
|
|
|
{ |
|
54
|
24
|
|
|
24
|
|
120
|
no strict 'refs'; |
|
|
24
|
|
|
|
|
28
|
|
|
|
24
|
|
|
|
|
4483
|
|
|
|
4730
|
|
|
|
|
3221
|
|
|
55
|
4730
|
|
100
|
|
|
2895
|
$o->prio($ { ref($o)."::DefaultPriority" } || Event::PRIO_NORMAL()); |
|
56
|
4730
|
100
|
|
|
|
6789
|
if (exists $arg->{nice}) { |
|
57
|
3
|
|
|
|
|
10
|
$o->prio($o->prio + delete $arg->{nice}); |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
$o->prio(-1) |
|
61
|
4730
|
100
|
|
|
|
6069
|
if delete $arg->{async}; |
|
62
|
|
|
|
|
|
|
$o->prio(delete $arg->{prio}) |
|
63
|
4730
|
100
|
|
|
|
8202
|
if exists $arg->{prio}; |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# is parked? |
|
66
|
4730
|
|
|
|
|
3518
|
my $parked = delete $arg->{parked}; |
|
67
|
|
|
|
|
|
|
|
|
68
|
4730
|
|
|
|
|
6949
|
for my $k (keys %$arg) { |
|
69
|
18695
|
|
|
|
|
11828
|
my $m = $k; |
|
70
|
18695
|
100
|
|
|
|
31683
|
if ($o->can($m)) { |
|
71
|
14056
|
|
|
|
|
23761
|
$o->$m($arg->{$k}); |
|
72
|
14055
|
|
|
|
|
14030
|
next; |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
4729
|
50
|
|
|
|
6903
|
Carp::cluck "creating ".ref($o)." desc='".$o->desc."'\n" |
|
77
|
|
|
|
|
|
|
if $Event::DebugLevel >= 3; |
|
78
|
|
|
|
|
|
|
|
|
79
|
4729
|
100
|
|
|
|
191381
|
$o->start unless $parked; |
|
80
|
4721
|
|
|
|
|
7652
|
$o; |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub attributes { |
|
84
|
24
|
|
|
24
|
|
94
|
no strict 'refs'; |
|
|
24
|
|
|
|
|
24
|
|
|
|
24
|
|
|
|
|
5282
|
|
|
85
|
3
|
|
|
3
|
0
|
6
|
my ($o) = @_; |
|
86
|
3
|
100
|
|
|
|
10
|
my $pk = ref $o? ref $o : $o; |
|
87
|
3
|
|
|
|
|
2
|
@{"$ {pk}::ATTRIBUTE"}, map { attributes($_) } @{"$ {pk}::ISA"}; |
|
|
3
|
|
|
|
|
13
|
|
|
|
2
|
|
|
|
|
7
|
|
|
|
3
|
|
|
|
|
23
|
|
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub configure { |
|
91
|
0
|
|
|
0
|
0
|
0
|
my $o = shift; |
|
92
|
0
|
0
|
|
|
|
0
|
if (! @_) { |
|
93
|
0
|
|
|
|
|
0
|
map { $_, $o->$_() } $o->attributes; |
|
|
0
|
|
|
|
|
0
|
|
|
94
|
|
|
|
|
|
|
} else { |
|
95
|
0
|
|
|
|
|
0
|
while (my ($k,$v)= splice @_, -2) { $o->$k($v)} |
|
|
0
|
|
|
|
|
0
|
|
|
96
|
|
|
|
|
|
|
1 # whatever |
|
97
|
0
|
|
|
|
|
0
|
} |
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub private { # assumes $self is a HASH ref |
|
101
|
6
|
|
|
6
|
0
|
7
|
my $self = shift; |
|
102
|
6
|
|
|
|
|
8
|
my $pkg = caller; |
|
103
|
6
|
100
|
|
|
|
11
|
if (@_) { |
|
104
|
2
|
|
|
|
|
7
|
$self->{$pkg} = shift |
|
105
|
|
|
|
|
|
|
} else { |
|
106
|
4
|
|
|
|
|
11
|
$self->{$pkg}; |
|
107
|
|
|
|
|
|
|
} |
|
108
|
|
|
|
|
|
|
} |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub data { # assumes $self is a HASH ref |
|
111
|
3
|
|
|
3
|
0
|
5
|
my $self = shift; |
|
112
|
3
|
100
|
|
|
|
5
|
if (@_) { |
|
113
|
|
|
|
|
|
|
$self->{_user_data_} = shift |
|
114
|
1
|
|
|
|
|
4
|
} else { |
|
115
|
2
|
|
|
|
|
8
|
$self->{_user_data_}; |
|
116
|
|
|
|
|
|
|
} |
|
117
|
|
|
|
|
|
|
} |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub clump { |
|
120
|
0
|
|
|
0
|
0
|
|
require Carp; |
|
121
|
0
|
|
|
|
|
|
Carp::cluck "clump is deprecated"; |
|
122
|
|
|
|
|
|
|
} |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
package Event::Watcher::Tied; |
|
125
|
24
|
|
|
24
|
|
91
|
use vars qw(@ISA @ATTRIBUTE); |
|
|
24
|
|
|
|
|
34
|
|
|
|
24
|
|
|
|
|
1488
|
|
|
126
|
|
|
|
|
|
|
@ISA = 'Event::Watcher'; |
|
127
|
|
|
|
|
|
|
@ATTRIBUTE = qw(hard at flags); |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
1; |