line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
MODULE = ZMQ::Raw PACKAGE = ZMQ::Raw::Poller |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
SV * |
4
|
|
|
|
|
|
|
new (class) |
5
|
|
|
|
|
|
|
SV *class |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
PREINIT: |
8
|
5
|
|
|
|
|
|
zmq_raw_poller *poller = NULL; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
CODE: |
11
|
5
|
|
|
|
|
|
Newxz (poller, 1, zmq_raw_poller); |
12
|
5
|
|
|
|
|
|
poller->poller = zmq_poller_new(); |
13
|
5
|
|
|
|
|
|
poller->events = zmq_raw_event_map_create(); |
14
|
5
|
|
|
|
|
|
poller->interested = zmq_raw_event_map_create(); |
15
|
5
|
50
|
|
|
|
|
if (poller->events == NULL || poller->interested == NULL || poller->poller == NULL) |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
16
|
|
|
|
|
|
|
{ |
17
|
0
|
|
|
|
|
|
zmq_raw_event_map_destroy (poller->events); |
18
|
0
|
|
|
|
|
|
zmq_raw_event_map_destroy (poller->interested); |
19
|
0
|
|
|
|
|
|
zmq_poller_destroy (&poller->poller); |
20
|
0
|
|
|
|
|
|
Safefree (poller); |
21
|
0
|
0
|
|
|
|
|
zmq_raw_check_error (-1); |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
5
|
|
|
|
|
|
ZMQ_NEW_OBJ (RETVAL, "ZMQ::Raw::Poller", poller); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
OUTPUT: RETVAL |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
void |
29
|
|
|
|
|
|
|
add (self, socket, events) |
30
|
|
|
|
|
|
|
SV *self |
31
|
|
|
|
|
|
|
SV *socket |
32
|
|
|
|
|
|
|
short events |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
PREINIT: |
35
|
|
|
|
|
|
|
zmq_raw_poller *poller; |
36
|
|
|
|
|
|
|
int rc; |
37
|
|
|
|
|
|
|
PerlIO *io; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
CODE: |
40
|
115
|
|
|
|
|
|
poller = ZMQ_SV_TO_PTR (Poller, self); |
41
|
|
|
|
|
|
|
|
42
|
115
|
|
|
|
|
|
io = zmq_get_socket_io (socket); |
43
|
115
|
100
|
|
|
|
|
if (io) |
44
|
|
|
|
|
|
|
{ |
45
|
1
|
50
|
|
|
|
|
if (zmq_raw_event_map_get (poller->interested, SvRV (socket))) |
46
|
0
|
|
|
|
|
|
rc = zmq_poller_modify_fd (poller->poller, zmq_get_native_socket (io), |
47
|
|
|
|
|
|
|
events); |
48
|
|
|
|
|
|
|
else |
49
|
1
|
|
|
|
|
|
rc = zmq_poller_add_fd (poller->poller, zmq_get_native_socket (io), |
50
|
1
|
|
|
|
|
|
SvRV (socket), events); |
51
|
1
|
50
|
|
|
|
|
zmq_raw_check_error (rc); |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
else |
54
|
|
|
|
|
|
|
{ |
55
|
114
|
|
|
|
|
|
zmq_raw_socket *sock = ZMQ_SV_TO_PTR (Socket, socket); |
56
|
|
|
|
|
|
|
|
57
|
113
|
100
|
|
|
|
|
if (zmq_raw_event_map_get (poller->interested, SvRV (socket))) |
58
|
3
|
|
|
|
|
|
rc = zmq_poller_modify (poller->poller, sock->socket, |
59
|
|
|
|
|
|
|
events); |
60
|
|
|
|
|
|
|
else |
61
|
110
|
|
|
|
|
|
rc = zmq_poller_add (poller->poller, sock->socket, |
62
|
110
|
|
|
|
|
|
SvRV (socket), events); |
63
|
113
|
50
|
|
|
|
|
zmq_raw_check_error (rc); |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
114
|
100
|
|
|
|
|
if (!zmq_raw_event_map_get (poller->interested, SvRV (socket))) |
67
|
|
|
|
|
|
|
{ |
68
|
111
|
|
|
|
|
|
zmq_raw_event_map_add (poller->interested, SvRV (socket), events); |
69
|
111
|
|
|
|
|
|
SvREFCNT_inc (SvRV (socket)); |
70
|
111
|
|
|
|
|
|
++poller->size; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
114
|
100
|
|
|
|
|
if (poller->size > poller->allocated) |
74
|
|
|
|
|
|
|
{ |
75
|
17
|
100
|
|
|
|
|
if (poller->poller_events) |
76
|
12
|
|
|
|
|
|
Safefree (poller->poller_events); |
77
|
|
|
|
|
|
|
|
78
|
17
|
50
|
|
|
|
|
Newxz (poller->poller_events, poller->size, zmq_poller_event_t); |
79
|
17
|
|
|
|
|
|
poller->allocated = poller->size; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
void |
84
|
|
|
|
|
|
|
remove(self, socket) |
85
|
|
|
|
|
|
|
SV *self |
86
|
|
|
|
|
|
|
SV *socket |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
PREINIT: |
89
|
|
|
|
|
|
|
zmq_raw_poller *poller; |
90
|
|
|
|
|
|
|
int rc; |
91
|
|
|
|
|
|
|
PerlIO *io; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
CODE: |
94
|
113
|
|
|
|
|
|
poller = ZMQ_SV_TO_PTR (Poller, self); |
95
|
|
|
|
|
|
|
|
96
|
113
|
|
|
|
|
|
io = zmq_get_socket_io (socket); |
97
|
113
|
100
|
|
|
|
|
if (io) |
98
|
|
|
|
|
|
|
{ |
99
|
1
|
|
|
|
|
|
rc = zmq_poller_remove_fd (poller->poller, zmq_get_native_socket (io)); |
100
|
1
|
50
|
|
|
|
|
if (rc != 0) |
101
|
0
|
|
|
|
|
|
XSRETURN_NO; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
else |
104
|
|
|
|
|
|
|
{ |
105
|
112
|
|
|
|
|
|
zmq_raw_socket *sock = ZMQ_SV_TO_PTR (Socket, socket); |
106
|
|
|
|
|
|
|
|
107
|
112
|
|
|
|
|
|
rc = zmq_poller_remove (poller->poller, sock->socket); |
108
|
112
|
100
|
|
|
|
|
if (rc != 0) |
109
|
4
|
|
|
|
|
|
XSRETURN_NO; |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
109
|
|
|
|
|
|
SvREFCNT_dec (SvRV (socket)); |
113
|
109
|
|
|
|
|
|
--poller->size; |
114
|
|
|
|
|
|
|
|
115
|
109
|
|
|
|
|
|
zmq_raw_event_map_remove (poller->interested, SvRV (socket)); |
116
|
|
|
|
|
|
|
|
117
|
109
|
|
|
|
|
|
XSRETURN_YES; |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
SV * |
120
|
|
|
|
|
|
|
size (self) |
121
|
|
|
|
|
|
|
SV *self |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
PREINIT: |
124
|
|
|
|
|
|
|
zmq_raw_poller *poller; |
125
|
|
|
|
|
|
|
SSize_t size; |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
CODE: |
128
|
130
|
|
|
|
|
|
poller = ZMQ_SV_TO_PTR (Poller, self); |
129
|
130
|
|
|
|
|
|
RETVAL = newSViv ((IV)poller->size); |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
OUTPUT: RETVAL |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
void |
134
|
|
|
|
|
|
|
wait (self, timeout) |
135
|
|
|
|
|
|
|
SV *self |
136
|
|
|
|
|
|
|
long timeout |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
PREINIT: |
139
|
|
|
|
|
|
|
int i, count, rc; |
140
|
81
|
|
|
|
|
|
zmq_raw_poller *poller = NULL; |
141
|
|
|
|
|
|
|
SSize_t size; |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
CODE: |
144
|
81
|
|
|
|
|
|
poller = ZMQ_SV_TO_PTR (Poller, self); |
145
|
|
|
|
|
|
|
|
146
|
81
|
|
|
|
|
|
zmq_raw_event_map_clear (poller->events); |
147
|
|
|
|
|
|
|
|
148
|
81
|
|
|
|
|
|
rc = zmq_poller_wait_all (poller->poller, poller->poller_events, poller->size, timeout); |
149
|
81
|
100
|
|
|
|
|
if (rc < 0) |
150
|
|
|
|
|
|
|
{ |
151
|
14
|
100
|
|
|
|
|
if (zmq_errno() == EAGAIN) |
152
|
13
|
|
|
|
|
|
XSRETURN_IV (0); |
153
|
|
|
|
|
|
|
|
154
|
1
|
50
|
|
|
|
|
zmq_raw_check_error (rc); |
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
|
157
|
67
|
|
|
|
|
|
count = 0; |
158
|
|
|
|
|
|
|
|
159
|
135
|
100
|
|
|
|
|
for (i = 0; i < poller->size && rc; ++i) |
|
|
100
|
|
|
|
|
|
160
|
|
|
|
|
|
|
{ |
161
|
68
|
|
|
|
|
|
zmq_poller_event_t *e = poller->poller_events+i; |
162
|
|
|
|
|
|
|
|
163
|
68
|
50
|
|
|
|
|
if (e->events) |
164
|
|
|
|
|
|
|
{ |
165
|
68
|
|
|
|
|
|
const short *events = zmq_raw_event_map_get (poller->interested, e->user_data); |
166
|
|
|
|
|
|
|
assert (events); |
167
|
|
|
|
|
|
|
|
168
|
68
|
100
|
|
|
|
|
if (e->events & *events) |
169
|
|
|
|
|
|
|
{ |
170
|
67
|
|
|
|
|
|
zmq_raw_event_map_add (poller->events, e->user_data, e->events & *events); |
171
|
67
|
|
|
|
|
|
++count; |
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
|
174
|
68
|
|
|
|
|
|
--rc; |
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
} |
177
|
|
|
|
|
|
|
|
178
|
67
|
|
|
|
|
|
XSRETURN_IV (count); |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
void |
181
|
|
|
|
|
|
|
events(self, socket) |
182
|
|
|
|
|
|
|
SV *self |
183
|
|
|
|
|
|
|
SV *socket |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
PREINIT: |
186
|
172
|
|
|
|
|
|
zmq_raw_poller *poller = NULL; |
187
|
|
|
|
|
|
|
const short *e; |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
CODE: |
190
|
172
|
|
|
|
|
|
poller = ZMQ_SV_TO_PTR (Poller, self); |
191
|
|
|
|
|
|
|
|
192
|
172
|
100
|
|
|
|
|
if (!zmq_raw_event_map_get (poller->interested, SvRV (socket))) |
193
|
1
|
|
|
|
|
|
XSRETURN_UNDEF; |
194
|
|
|
|
|
|
|
|
195
|
171
|
|
|
|
|
|
e = zmq_raw_event_map_get (poller->events, SvRV (socket)); |
196
|
171
|
100
|
|
|
|
|
if (e == NULL) |
197
|
109
|
|
|
|
|
|
XSRETURN_IV (0); |
198
|
|
|
|
|
|
|
|
199
|
62
|
|
|
|
|
|
XSRETURN_IV (*e); |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
void |
202
|
|
|
|
|
|
|
DESTROY (self) |
203
|
|
|
|
|
|
|
SV *self |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
PREINIT: |
206
|
|
|
|
|
|
|
zmq_raw_poller *poller; |
207
|
|
|
|
|
|
|
zmq_raw_event_map_iterator *iterator; |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
CODE: |
210
|
5
|
|
|
|
|
|
poller = ZMQ_SV_TO_PTR (Poller, self); |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
/* cleanup */ |
213
|
5
|
|
|
|
|
|
iterator = zmq_raw_event_map_iterator_create (poller->interested); |
214
|
5
|
100
|
|
|
|
|
if (iterator) |
215
|
|
|
|
|
|
|
{ |
216
|
|
|
|
|
|
|
do |
217
|
|
|
|
|
|
|
{ |
218
|
2
|
|
|
|
|
|
SvREFCNT_dec (zmq_raw_event_map_iterator_key (iterator)); |
219
|
|
|
|
|
|
|
} |
220
|
2
|
100
|
|
|
|
|
while (zmq_raw_event_map_iterator_next (iterator)); |
221
|
|
|
|
|
|
|
|
222
|
1
|
|
|
|
|
|
zmq_raw_event_map_iterator_destroy (iterator); |
223
|
|
|
|
|
|
|
} |
224
|
|
|
|
|
|
|
|
225
|
5
|
|
|
|
|
|
zmq_raw_event_map_destroy (poller->interested); |
226
|
5
|
|
|
|
|
|
zmq_raw_event_map_destroy (poller->events); |
227
|
5
|
|
|
|
|
|
zmq_poller_destroy (&poller->poller); |
228
|
5
|
|
|
|
|
|
Safefree (poller); |
229
|
|
|
|
|
|
|
|