line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package ZMQ::Raw::Loop::Handle; |
2
|
|
|
|
|
|
|
$ZMQ::Raw::Loop::Handle::VERSION = '0.39'; |
3
|
14
|
|
|
14
|
|
96
|
use strict; |
|
14
|
|
|
|
|
28
|
|
|
14
|
|
|
|
|
401
|
|
4
|
14
|
|
|
14
|
|
108
|
use warnings; |
|
14
|
|
|
|
|
28
|
|
|
14
|
|
|
|
|
317
|
|
5
|
14
|
|
|
14
|
|
62
|
use Carp; |
|
14
|
|
|
|
|
24
|
|
|
14
|
|
|
|
|
717
|
|
6
|
14
|
|
|
14
|
|
81
|
use Scalar::Util qw/weaken/; |
|
14
|
|
|
|
|
26
|
|
|
14
|
|
|
|
|
1132
|
|
7
|
|
|
|
|
|
|
|
8
|
0
|
|
|
0
|
|
0
|
sub CLONE_SKIP { 1 } |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
my @attributes; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
BEGIN |
13
|
|
|
|
|
|
|
{ |
14
|
14
|
|
|
14
|
|
73
|
@attributes = qw/ |
15
|
|
|
|
|
|
|
handle |
16
|
|
|
|
|
|
|
timer |
17
|
|
|
|
|
|
|
timeout |
18
|
|
|
|
|
|
|
on_readable |
19
|
|
|
|
|
|
|
on_writable |
20
|
|
|
|
|
|
|
on_timeout |
21
|
|
|
|
|
|
|
/; |
22
|
|
|
|
|
|
|
|
23
|
14
|
|
|
14
|
|
112
|
no strict 'refs'; |
|
14
|
|
|
|
|
41
|
|
|
14
|
|
|
|
|
1365
|
|
24
|
14
|
|
|
|
|
36
|
foreach my $accessor (@attributes) |
25
|
|
|
|
|
|
|
{ |
26
|
84
|
|
|
|
|
736
|
*{$accessor} = sub |
27
|
|
|
|
|
|
|
{ |
28
|
48
|
100
|
|
48
|
|
341
|
@_ > 1 ? $_[0]->{$accessor} = $_[1] : $_[0]->{$accessor} |
|
|
|
|
48
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
48
|
|
|
|
29
|
84
|
|
|
|
|
296
|
}; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
14
|
|
|
14
|
|
132
|
use ZMQ::Raw; |
|
14
|
|
|
|
|
27
|
|
|
14
|
|
|
|
|
4262
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 NAME |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
ZMQ::Raw::Loop::Handle - Handle class |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 VERSION |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
version 0.39 |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 DESCRIPTION |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
A L represents a handle. |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
B: The API of this module is unstable and may change without warning |
48
|
|
|
|
|
|
|
(any change will be appropriately documented in the changelog). |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 SYNOPSIS |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
use ZMQ::Raw; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
my $handle = ZMQ::Raw::Loop::Handle->new |
55
|
|
|
|
|
|
|
( |
56
|
|
|
|
|
|
|
handle => $handle, |
57
|
|
|
|
|
|
|
timeout => 30, |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
on_readable => sub |
60
|
|
|
|
|
|
|
{ |
61
|
|
|
|
|
|
|
}, |
62
|
|
|
|
|
|
|
on_writable => sub |
63
|
|
|
|
|
|
|
{ |
64
|
|
|
|
|
|
|
}, |
65
|
|
|
|
|
|
|
on_timeout => sub |
66
|
|
|
|
|
|
|
{ |
67
|
|
|
|
|
|
|
}, |
68
|
|
|
|
|
|
|
); |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
my $loop = ZMQ::Raw::Loop->new; |
71
|
|
|
|
|
|
|
$loop->add ($handle); |
72
|
|
|
|
|
|
|
$loop->run; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 METHODS |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head2 new( %args ) |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Create a new handle. |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=cut |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub new |
83
|
|
|
|
|
|
|
{ |
84
|
9
|
|
|
9
|
1
|
3706
|
my ($this, %args) = @_; |
85
|
|
|
|
|
|
|
|
86
|
9
|
100
|
|
|
|
35
|
if (!$args{handle}) |
87
|
|
|
|
|
|
|
{ |
88
|
1
|
|
|
|
|
191
|
croak "handle not provided"; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
8
|
100
|
100
|
|
|
26
|
if (!$args{on_readable} && !$args{on_writable}) |
92
|
|
|
|
|
|
|
{ |
93
|
1
|
|
|
|
|
95
|
croak "on_readable or on_writable needed"; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
7
|
100
|
100
|
|
|
37
|
if ($args{on_readable} && ref ($args{on_readable}) ne 'CODE') |
97
|
|
|
|
|
|
|
{ |
98
|
1
|
|
|
|
|
113
|
croak "on_readable not a code ref"; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
6
|
100
|
66
|
|
|
21
|
if ($args{on_writable} && ref ($args{on_writable}) ne 'CODE') |
102
|
|
|
|
|
|
|
{ |
103
|
1
|
|
|
|
|
95
|
croak "on_writable not a code ref"; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
5
|
100
|
66
|
|
|
26
|
if ($args{on_timeout} && ref ($args{on_timeout}) ne 'CODE') |
107
|
|
|
|
|
|
|
{ |
108
|
1
|
|
|
|
|
84
|
croak "on_timeout not a code ref"; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
4
|
100
|
66
|
|
|
19
|
if ($args{on_timeout} && !exists ($args{timeout})) |
112
|
|
|
|
|
|
|
{ |
113
|
1
|
|
|
|
|
84
|
croak "on_timeout provided but timeout not set"; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
3
|
|
33
|
|
|
14
|
my $class = ref ($this) || $this; |
117
|
|
|
|
|
|
|
my $self = |
118
|
|
|
|
|
|
|
{ |
119
|
|
|
|
|
|
|
handle => $args{handle}, |
120
|
|
|
|
|
|
|
timeout => $args{timeout}, |
121
|
|
|
|
|
|
|
on_readable => $args{on_readable}, |
122
|
|
|
|
|
|
|
on_writable => $args{on_writable}, |
123
|
|
|
|
|
|
|
on_timeout => $args{on_timeout}, |
124
|
3
|
|
|
|
|
15
|
}; |
125
|
|
|
|
|
|
|
|
126
|
3
|
|
|
|
|
85
|
return bless $self, $class; |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
sub loop |
132
|
|
|
|
|
|
|
{ |
133
|
4
|
|
|
4
|
0
|
11
|
my ($this, $loop) = @_; |
134
|
|
|
|
|
|
|
|
135
|
4
|
50
|
|
|
|
13
|
if (scalar (@_) > 1) |
136
|
|
|
|
|
|
|
{ |
137
|
4
|
|
|
|
|
9
|
$this->{loop} = $loop; |
138
|
4
|
|
|
|
|
13
|
weaken ($this->{loop}); |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
4
|
|
|
|
|
9
|
return $this->{loop}; |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=for Pod::Coverage handle timer loop timeout on_readable on_writable on_timeout |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head1 AUTHOR |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Jacques Germishuys |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
Copyright 2017 Jacques Germishuys. |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
155
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
156
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=cut |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
1; # End of ZMQ::Raw::Loop::Handle |