line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package UV::Loop; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '1.901'; |
4
|
|
|
|
|
|
|
|
5
|
42
|
|
|
42
|
|
122338
|
use strict; |
|
42
|
|
|
|
|
198
|
|
|
42
|
|
|
|
|
1195
|
|
6
|
42
|
|
|
42
|
|
212
|
use warnings; |
|
42
|
|
|
|
|
68
|
|
|
42
|
|
|
|
|
932
|
|
7
|
|
|
|
|
|
|
|
8
|
42
|
|
|
42
|
|
189
|
use Carp (); |
|
42
|
|
|
|
|
76
|
|
|
42
|
|
|
|
|
787
|
|
9
|
42
|
|
|
42
|
|
184
|
use Exporter qw(import); |
|
42
|
|
|
|
|
64
|
|
|
42
|
|
|
|
|
1532
|
|
10
|
42
|
|
|
42
|
|
333
|
use Scalar::Util (); |
|
42
|
|
|
|
|
83
|
|
|
42
|
|
|
|
|
741
|
|
11
|
42
|
|
|
42
|
|
8971
|
use UV (); |
|
42
|
|
|
|
|
86
|
|
|
42
|
|
|
|
|
1624
|
|
12
|
|
|
|
|
|
|
|
13
|
42
|
|
|
42
|
|
285
|
use constant DEBUG => $ENV{PERL_UV_DEBUG}; |
|
42
|
|
|
|
|
72
|
|
|
42
|
|
|
|
|
25422
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our @EXPORT_OK = (@UV::Loop::EXPORT_XS,); |
16
|
|
|
|
|
|
|
my $default_loop; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# simple function to ensure we've been given a UV::Loop |
19
|
|
|
|
|
|
|
# this is useful in new Handle construction |
20
|
|
|
|
|
|
|
sub _is_a_loop { |
21
|
0
|
|
|
0
|
|
0
|
my $loop = shift; |
22
|
0
|
0
|
|
|
|
0
|
return undef unless $loop; |
23
|
0
|
0
|
0
|
|
|
0
|
return undef unless ref($loop) && Scalar::Util::blessed($loop); |
24
|
0
|
0
|
|
|
|
0
|
return undef unless $loop->isa('UV::Loop'); |
25
|
0
|
|
|
|
|
0
|
return 1; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub new { |
29
|
30
|
|
|
30
|
1
|
694
|
my $class = shift; |
30
|
30
|
|
|
|
|
50
|
print STDERR "UV::Loop->new() called\n" if DEBUG; |
31
|
30
|
|
|
|
|
128
|
my $args = UV::_parse_args(@_); |
32
|
|
|
|
|
|
|
|
33
|
30
|
|
100
|
|
|
2992
|
my $self = $class->_new($args->{_default} // 0); |
34
|
|
|
|
|
|
|
|
35
|
30
|
|
|
|
|
302
|
$self->on('walk', $args->{on_walk}); |
36
|
30
|
|
|
|
|
87
|
print STDERR "UV::Loop->new() walk callback added\n" if DEBUG; |
37
|
|
|
|
|
|
|
|
38
|
30
|
|
|
|
|
49
|
print STDERR "UV::Loop->new() done\n" if DEBUG; |
39
|
30
|
|
|
|
|
106
|
return $self; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# Return the singleton uv_default_loop |
43
|
|
|
|
|
|
|
sub default { |
44
|
1710
|
|
|
1710
|
1
|
517934
|
print STDERR "loop default() singleton called\n" if DEBUG; |
45
|
1710
|
|
|
|
|
2648
|
my $class = shift; |
46
|
1710
|
100
|
|
|
|
3287
|
if (defined($default_loop)) { |
47
|
1684
|
|
|
|
|
1971
|
print STDERR "loop default() returning already stored default loop\n" if DEBUG; |
48
|
1684
|
|
|
|
|
125698
|
return $default_loop; |
49
|
|
|
|
|
|
|
} |
50
|
26
|
|
|
|
|
51
|
print STDERR "loop default() We don't have a default. Let's create one!\n" if DEBUG; |
51
|
26
|
|
|
|
|
107
|
$default_loop = $class->new(@_, _default => 1); |
52
|
26
|
|
|
|
|
51
|
print STDERR "loop default() returning newly created and stored default loop\n" if DEBUG; |
53
|
26
|
|
|
|
|
191
|
return $default_loop; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
1
|
|
|
1
|
1
|
713
|
sub default_loop { return shift->default(); } |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub on { |
59
|
35
|
|
|
35
|
1
|
78
|
my $self = shift; |
60
|
35
|
|
|
|
|
113
|
my $method = "_on_" . shift; |
61
|
35
|
|
|
|
|
303
|
return $self->$method( @_ ); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub walk { |
65
|
10
|
|
|
10
|
1
|
500268
|
my $self = shift; |
66
|
10
|
100
|
|
|
|
62
|
return unless $self->alive(); |
67
|
5
|
50
|
|
|
|
21
|
$self->on('walk', @_) if @_; # set the callback ahead of time if exists |
68
|
5
|
|
|
|
|
116
|
$self->_walk(); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub getaddrinfo { |
72
|
2
|
|
|
2
|
1
|
5034
|
my $self = shift; |
73
|
2
|
|
|
|
|
5
|
my ($args, $cb) = @_; |
74
|
|
|
|
|
|
|
|
75
|
2
|
|
|
|
|
3
|
$self->_getaddrinfo(@{$args}{qw( node service flags family socktype protocol )}, $cb); |
|
2
|
|
|
|
|
445
|
|
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
1; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
__END__ |