1 | #include "EXTERN.h" |
1 | #include "EXTERN.h" |
2 | #include "perl.h" |
2 | #include "perl.h" |
3 | #include "XSUB.h" |
3 | #include "XSUB.h" |
4 | |
4 | |
5 | /*#include <netinet/in.h>*/ |
5 | /* fix perl api breakage */ |
|
|
6 | #undef signal |
|
|
7 | #undef sigaction |
6 | |
8 | |
7 | #define TIMEOUT_NONE HUGE_VAL |
9 | #include "schmorp.h" |
8 | #define EV_USE_EPOLL 1 |
|
|
9 | |
10 | |
|
|
11 | /* old API compatibility */ |
|
|
12 | static int |
|
|
13 | sv_fileno (SV *fh) |
|
|
14 | { |
|
|
15 | return s_fileno (fh, 0); |
|
|
16 | } |
|
|
17 | |
|
|
18 | #ifndef GvCV_set |
|
|
19 | # define GvCV_set(gv,cv) GvCV (gv) = cv |
|
|
20 | #endif |
|
|
21 | |
|
|
22 | #define EV_STANDALONE 1 |
10 | #define EV_PROTOTYPES 1 |
23 | #define EV_PROTOTYPES 1 |
|
|
24 | #define EV_USE_NANOSLEEP EV_USE_MONOTONIC |
|
|
25 | #define EV_USE_FLOOR 1 |
|
|
26 | #define EV_API_STATIC |
|
|
27 | #define EV_H <ev.h> |
|
|
28 | #define EV_CONFIG_H error |
11 | #include "EV/EVAPI.h" |
29 | #include "EV/EVAPI.h" |
12 | |
30 | |
|
|
31 | #define EV_SELECT_IS_WINSOCKET 0 |
|
|
32 | #ifdef _WIN32 |
|
|
33 | # define EV_SELECT_USE_FD_SET 0 |
|
|
34 | # define NFDBITS PERL_NFDBITS |
|
|
35 | # define fd_mask Perl_fd_mask |
|
|
36 | #endif |
|
|
37 | /* due to bugs in OS X we have to use libev/ explicitly here */ |
13 | #include "libev/ev.c" |
38 | #include "libev/ev.c" |
14 | |
39 | |
|
|
40 | #if !defined _WIN32 && !defined _MINIX |
|
|
41 | # include <pthread.h> |
|
|
42 | #endif |
|
|
43 | |
|
|
44 | #define e_loop(w) INT2PTR (struct ev_loop *, SvIVX (((ev_watcher *)(w))->loop)) |
|
|
45 | #define e_flags(w) ((ev_watcher *)(w))->e_flags |
|
|
46 | #define e_self(w) ((ev_watcher *)(w))->self |
|
|
47 | #define e_fh(w) ((ev_watcher *)(w))->fh |
|
|
48 | #define e_data(w) ((ev_watcher *)(w))->data |
|
|
49 | |
|
|
50 | #define WFLAG_KEEPALIVE 1 |
|
|
51 | #define WFLAG_UNREFED 2 /* has been unref'ed */ |
|
|
52 | #define WFLAG_NOARGS 4 /* do not pass anything to the callback */ |
|
|
53 | |
|
|
54 | #define UNREF(w) \ |
|
|
55 | if (!(e_flags (w) & (WFLAG_KEEPALIVE | WFLAG_UNREFED)) \ |
|
|
56 | && ev_is_active (w)) \ |
|
|
57 | { \ |
|
|
58 | ev_unref (e_loop (w)); \ |
|
|
59 | e_flags (w) |= WFLAG_UNREFED; \ |
|
|
60 | } |
|
|
61 | |
|
|
62 | #define REF(w) \ |
|
|
63 | if (e_flags (w) & WFLAG_UNREFED) \ |
|
|
64 | { \ |
|
|
65 | e_flags (w) &= ~WFLAG_UNREFED; \ |
|
|
66 | ev_ref (e_loop (w)); \ |
|
|
67 | } |
|
|
68 | |
|
|
69 | #define START(type,w) \ |
|
|
70 | do { \ |
|
|
71 | ev_ ## type ## _start (e_loop (w), w); \ |
|
|
72 | UNREF (w); \ |
|
|
73 | } while (0) |
|
|
74 | |
|
|
75 | #define STOP(type,w) \ |
|
|
76 | do { \ |
|
|
77 | REF (w); \ |
|
|
78 | ev_ ## type ## _stop (e_loop (w), w); \ |
|
|
79 | } while (0) |
|
|
80 | |
|
|
81 | #define RESET(type,w,seta) \ |
|
|
82 | do { \ |
|
|
83 | int active = ev_is_active (w); \ |
|
|
84 | if (active) STOP (type, w); \ |
|
|
85 | ev_ ## type ## _set seta; \ |
|
|
86 | if (active) START (type, w); \ |
|
|
87 | } while (0) |
|
|
88 | |
15 | typedef int Signal; |
89 | typedef int Signal; |
16 | |
90 | |
|
|
91 | /* horrible... */ |
|
|
92 | #define CHECK_SIGNAL_CAN_START(w) \ |
|
|
93 | do { \ |
|
|
94 | /* dive into the internals of libev to avoid aborting in libev */ \ |
|
|
95 | if (signals [(w)->signum - 1].loop \ |
|
|
96 | && signals [(w)->signum - 1].loop != e_loop (w)) \ |
|
|
97 | croak ("unable to start signal watcher, signal %d already registered in another loop", w->signum); \ |
|
|
98 | } while (0) |
|
|
99 | |
|
|
100 | #define START_SIGNAL(w) \ |
|
|
101 | do { \ |
|
|
102 | CHECK_SIGNAL_CAN_START (w); \ |
|
|
103 | START (signal, w); \ |
|
|
104 | } while (0) \ |
|
|
105 | |
|
|
106 | #define RESET_SIGNAL(w,seta) \ |
|
|
107 | do { \ |
|
|
108 | int active = ev_is_active (w); \ |
|
|
109 | if (active) STOP (signal, w); \ |
|
|
110 | ev_ ## signal ## _set seta; \ |
|
|
111 | if (active) START_SIGNAL (w); \ |
|
|
112 | } while (0) |
|
|
113 | |
|
|
114 | static SV *default_loop_sv; |
|
|
115 | |
17 | static struct EVAPI evapi; |
116 | static struct EVAPI evapi; |
18 | |
117 | |
19 | static HV |
118 | static HV |
|
|
119 | *stash_loop, |
20 | *stash_watcher, |
120 | *stash_watcher, |
21 | *stash_io, |
121 | *stash_io, |
22 | *stash_timer, |
122 | *stash_timer, |
23 | *stash_periodic, |
123 | *stash_periodic, |
24 | *stash_signal, |
124 | *stash_signal, |
|
|
125 | *stash_child, |
|
|
126 | *stash_stat, |
25 | *stash_idle, |
127 | *stash_idle, |
26 | *stash_prepare, |
128 | *stash_prepare, |
27 | *stash_check, |
129 | *stash_check, |
28 | *stash_child; |
130 | *stash_embed, |
29 | |
131 | *stash_fork, |
30 | static int |
132 | *stash_cleanup, |
31 | sv_signum (SV *sig) |
133 | *stash_async; |
32 | { |
|
|
33 | int signum; |
|
|
34 | |
|
|
35 | SvGETMAGIC (sig); |
|
|
36 | |
|
|
37 | for (signum = 1; signum < SIG_SIZE; ++signum) |
|
|
38 | if (strEQ (SvPV_nolen (sig), PL_sig_name [signum])) |
|
|
39 | return signum; |
|
|
40 | |
|
|
41 | if (SvIV (sig) > 0) |
|
|
42 | return SvIV (sig); |
|
|
43 | |
|
|
44 | return -1; |
|
|
45 | } |
|
|
46 | |
134 | |
47 | ///////////////////////////////////////////////////////////////////////////// |
135 | ///////////////////////////////////////////////////////////////////////////// |
48 | // Event |
136 | // Event |
49 | |
137 | |
50 | static void e_cb (struct ev_watcher *w, int revents); |
138 | static void e_cb (EV_P_ ev_watcher *w, int revents); |
51 | |
|
|
52 | static int |
|
|
53 | sv_fileno (SV *fh) |
|
|
54 | { |
|
|
55 | SvGETMAGIC (fh); |
|
|
56 | |
|
|
57 | if (SvROK (fh)) |
|
|
58 | fh = SvRV (fh); |
|
|
59 | |
|
|
60 | if (SvTYPE (fh) == SVt_PVGV) |
|
|
61 | return PerlIO_fileno (IoIFP (sv_2io (fh))); |
|
|
62 | |
|
|
63 | if ((SvIV (fh) >= 0) && (SvIV (fh) < 0x7ffffff)) |
|
|
64 | return SvIV (fh); |
|
|
65 | |
|
|
66 | return -1; |
|
|
67 | } |
|
|
68 | |
139 | |
69 | static void * |
140 | static void * |
70 | e_new (int size, SV *cb_sv) |
141 | e_new (int size, SV *cb_sv, SV *loop) |
71 | { |
142 | { |
|
|
143 | SV *cv = cb_sv ? s_get_cv_croak (cb_sv) : 0; |
72 | struct ev_watcher *w; |
144 | ev_watcher *w; |
73 | SV *self = NEWSV (0, size); |
145 | SV *self = NEWSV (0, size); |
74 | SvPOK_only (self); |
146 | SvPOK_only (self); |
75 | SvCUR_set (self, size); |
147 | SvCUR_set (self, size); |
76 | |
148 | |
77 | w = (struct ev_watcher *)SvPVX (self); |
149 | w = (ev_watcher *)SvPVX (self); |
78 | |
150 | |
79 | ev_watcher_init (w, e_cb); |
151 | ev_init (w, cv ? e_cb : 0); |
80 | |
152 | |
|
|
153 | w->loop = SvREFCNT_inc (SvRV (loop)); |
|
|
154 | w->e_flags = WFLAG_KEEPALIVE; |
|
|
155 | w->data = 0; |
81 | w->fh = 0; |
156 | w->fh = 0; |
82 | w->cb_sv = newSVsv (cb_sv); |
157 | w->cb_sv = SvREFCNT_inc (cv); |
83 | w->self = self; |
158 | w->self = self; |
84 | |
159 | |
85 | return (void *)w; |
160 | return (void *)w; |
86 | } |
161 | } |
87 | |
162 | |
88 | static void * |
163 | static void |
89 | e_destroy (void *w_) |
164 | e_destroy (void *w_) |
90 | { |
165 | { |
91 | struct ev_watcher *w = w_; |
166 | ev_watcher *w = (ev_watcher *)w_; |
92 | |
167 | |
|
|
168 | SvREFCNT_dec (w->loop ); w->loop = 0; |
93 | SvREFCNT_dec (w->fh ); w->fh = 0; |
169 | SvREFCNT_dec (w->fh ); w->fh = 0; |
94 | SvREFCNT_dec (w->cb_sv); w->cb_sv = 0; |
170 | SvREFCNT_dec (w->cb_sv); w->cb_sv = 0; |
|
|
171 | SvREFCNT_dec (w->data ); w->data = 0; |
95 | } |
172 | } |
96 | |
173 | |
97 | static SV * |
174 | static SV * |
98 | e_bless (struct ev_watcher *w, HV *stash) |
175 | e_bless (ev_watcher *w, HV *stash) |
99 | { |
176 | { |
100 | SV *rv; |
177 | SV *rv; |
101 | |
178 | |
102 | if (SvOBJECT (w->self)) |
179 | if (SvOBJECT (w->self)) |
103 | rv = newRV_inc (w->self); |
180 | rv = newRV_inc (w->self); |
… | |
… | |
109 | } |
186 | } |
110 | |
187 | |
111 | return rv; |
188 | return rv; |
112 | } |
189 | } |
113 | |
190 | |
|
|
191 | static SV *sv_self_cache, *sv_events_cache; |
|
|
192 | |
114 | static void |
193 | static void |
115 | e_cb (struct ev_watcher *w, int revents) |
194 | e_cb (EV_P_ ev_watcher *w, int revents) |
116 | { |
195 | { |
117 | dSP; |
196 | dSP; |
118 | I32 mark = SP - PL_stack_base; |
197 | I32 mark = SP - PL_stack_base; |
119 | SV *sv_self, *sv_events, *sv_status = 0; |
198 | SV *sv_self, *sv_events; |
120 | static SV *sv_events_cache; |
|
|
121 | |
199 | |
|
|
200 | /* libev might have stopped the watcher */ |
|
|
201 | if (expect_false (w->e_flags & WFLAG_UNREFED) |
|
|
202 | && !ev_is_active (w)) |
|
|
203 | REF (w); |
|
|
204 | |
|
|
205 | PUSHMARK (SP); |
|
|
206 | |
|
|
207 | if (!expect_true (e_flags (w) & WFLAG_NOARGS)) |
|
|
208 | { |
|
|
209 | if (expect_true (sv_self_cache)) |
|
|
210 | { |
|
|
211 | sv_self = sv_self_cache; sv_self_cache = 0; |
|
|
212 | SvRV_set (sv_self, SvREFCNT_inc_NN (w->self)); |
|
|
213 | } |
|
|
214 | else |
|
|
215 | { |
122 | sv_self = newRV_inc (w->self); /* w->self MUST be blessed by now */ |
216 | sv_self = newRV_inc (w->self); /* e_self (w) MUST be blessed by now */ |
|
|
217 | SvREADONLY_on (sv_self); |
|
|
218 | } |
|
|
219 | |
|
|
220 | if (expect_true (sv_events_cache)) |
|
|
221 | { |
|
|
222 | sv_events = sv_events_cache; sv_events_cache = 0; |
|
|
223 | SvIV_set (sv_events, revents); |
|
|
224 | SvIOK_only (sv_events); |
|
|
225 | } |
|
|
226 | else |
|
|
227 | { |
|
|
228 | sv_events = newSViv (revents); |
|
|
229 | SvREADONLY_on (sv_events); |
|
|
230 | } |
|
|
231 | |
|
|
232 | EXTEND (SP, 2); |
|
|
233 | PUSHs (sv_self); |
|
|
234 | PUSHs (sv_events); |
|
|
235 | |
|
|
236 | PUTBACK; |
|
|
237 | call_sv (w->cb_sv, G_DISCARD | G_VOID | G_EVAL); |
|
|
238 | |
|
|
239 | if (expect_false (SvREFCNT (sv_self) != 1 || sv_self_cache)) |
|
|
240 | SvREFCNT_dec (sv_self); |
|
|
241 | else |
|
|
242 | { |
|
|
243 | SvREFCNT_dec (SvRV (sv_self)); |
|
|
244 | SvRV_set (sv_self, &PL_sv_undef); |
|
|
245 | sv_self_cache = sv_self; |
|
|
246 | } |
|
|
247 | |
|
|
248 | if (expect_false (SvREFCNT (sv_events) != 1 || sv_events_cache)) |
|
|
249 | SvREFCNT_dec (sv_events); |
|
|
250 | else |
|
|
251 | sv_events_cache = sv_events; |
|
|
252 | } |
|
|
253 | else |
|
|
254 | { |
|
|
255 | EXTEND (SP, 2); |
|
|
256 | PUSHs (sv_self); |
|
|
257 | PUSHs (sv_events); |
|
|
258 | |
|
|
259 | PUTBACK; |
|
|
260 | call_sv (w->cb_sv, G_DISCARD | G_VOID | G_EVAL); |
|
|
261 | } |
|
|
262 | |
|
|
263 | if (expect_false (SvTRUE (ERRSV))) |
|
|
264 | { |
|
|
265 | SPAGAIN; |
|
|
266 | PUSHMARK (SP); |
|
|
267 | PUTBACK; |
|
|
268 | call_sv (get_sv ("EV::DIED", 1), G_DISCARD | G_VOID | G_EVAL | G_KEEPERR); |
|
|
269 | } |
|
|
270 | |
|
|
271 | SP = PL_stack_base + mark; |
|
|
272 | PUTBACK; |
|
|
273 | } |
|
|
274 | |
|
|
275 | static void |
|
|
276 | e_once_cb (int revents, void *arg) |
|
|
277 | { |
|
|
278 | dSP; |
|
|
279 | I32 mark = SP - PL_stack_base; |
|
|
280 | SV *sv_events; |
123 | |
281 | |
124 | if (sv_events_cache) |
282 | if (sv_events_cache) |
125 | { |
283 | { |
126 | sv_events = sv_events_cache; sv_events_cache = 0; |
284 | sv_events = sv_events_cache; sv_events_cache = 0; |
127 | SvIV_set (sv_events, revents); |
285 | SvIV_set (sv_events, revents); |
128 | } |
286 | } |
129 | else |
287 | else |
130 | sv_events = newSViv (revents); |
288 | sv_events = newSViv (revents); |
131 | |
289 | |
132 | PUSHMARK (SP); |
290 | PUSHMARK (SP); |
133 | EXTEND (SP, 2); |
|
|
134 | PUSHs (sv_self); |
|
|
135 | PUSHs (sv_events); |
291 | XPUSHs (sv_events); |
136 | |
|
|
137 | if (revents & EV_CHILD) |
|
|
138 | XPUSHs (sv_status = newSViv (((struct ev_child *)w)->status)); |
|
|
139 | |
292 | |
140 | PUTBACK; |
293 | PUTBACK; |
141 | call_sv (w->cb_sv, G_DISCARD | G_VOID | G_EVAL); |
294 | call_sv ((SV *)arg, G_DISCARD | G_VOID | G_EVAL); |
142 | SP = PL_stack_base + mark; PUTBACK; |
|
|
143 | |
295 | |
144 | SvREFCNT_dec (sv_self); |
296 | SvREFCNT_dec ((SV *)arg); |
145 | SvREFCNT_dec (sv_status); |
|
|
146 | |
297 | |
147 | if (sv_events_cache) |
298 | if (sv_events_cache) |
148 | SvREFCNT_dec (sv_events); |
299 | SvREFCNT_dec (sv_events); |
149 | else |
300 | else |
150 | sv_events_cache = sv_events; |
301 | sv_events_cache = sv_events; |
|
|
302 | |
|
|
303 | if (SvTRUE (ERRSV)) |
|
|
304 | { |
|
|
305 | SPAGAIN; |
|
|
306 | PUSHMARK (SP); |
|
|
307 | PUTBACK; |
|
|
308 | call_sv (get_sv ("EV::DIED", 1), G_DISCARD | G_VOID | G_EVAL | G_KEEPERR); |
|
|
309 | } |
|
|
310 | |
|
|
311 | SP = PL_stack_base + mark; |
|
|
312 | PUTBACK; |
|
|
313 | } |
|
|
314 | |
|
|
315 | static ev_tstamp |
|
|
316 | e_periodic_cb (ev_periodic *w, ev_tstamp now) |
|
|
317 | { |
|
|
318 | ev_tstamp retval; |
|
|
319 | int count; |
|
|
320 | dSP; |
|
|
321 | |
|
|
322 | ENTER; |
|
|
323 | SAVETMPS; |
|
|
324 | |
|
|
325 | PUSHMARK (SP); |
|
|
326 | EXTEND (SP, 2); |
|
|
327 | PUSHs (newRV_inc (e_self (w))); /* e_self (w) MUST be blessed by now */ |
|
|
328 | PUSHs (newSVnv (now)); |
|
|
329 | |
|
|
330 | PUTBACK; |
|
|
331 | count = call_sv (w->fh, G_SCALAR | G_EVAL); |
|
|
332 | SPAGAIN; |
151 | |
333 | |
152 | if (SvTRUE (ERRSV)) |
334 | if (SvTRUE (ERRSV)) |
153 | { |
335 | { |
154 | PUSHMARK (SP); |
336 | PUSHMARK (SP); |
155 | PUTBACK; |
337 | PUTBACK; |
156 | call_sv (get_sv ("EV::DIED", 1), G_DISCARD | G_VOID | G_EVAL | G_KEEPERR); |
338 | call_sv (get_sv ("EV::DIED", 1), G_DISCARD | G_VOID | G_EVAL | G_KEEPERR); |
157 | SP = PL_stack_base + mark; PUTBACK; |
339 | SPAGAIN; |
158 | } |
340 | } |
159 | } |
|
|
160 | |
341 | |
161 | #if 0 |
342 | if (count > 0) |
162 | ///////////////////////////////////////////////////////////////////////////// |
|
|
163 | // DNS |
|
|
164 | |
|
|
165 | static void |
|
|
166 | dns_cb (int result, char type, int count, int ttl, void *addresses, void *arg) |
|
|
167 | { |
|
|
168 | dSP; |
|
|
169 | SV *cb = (SV *)arg; |
|
|
170 | |
|
|
171 | ENTER; |
|
|
172 | SAVETMPS; |
|
|
173 | PUSHMARK (SP); |
|
|
174 | EXTEND (SP, count + 3); |
|
|
175 | PUSHs (sv_2mortal (newSViv (result))); |
|
|
176 | |
|
|
177 | if (result == DNS_ERR_NONE && ttl >= 0) |
|
|
178 | { |
343 | { |
179 | int i; |
344 | retval = SvNV (TOPs); |
180 | |
345 | |
181 | PUSHs (sv_2mortal (newSViv (type))); |
346 | if (retval < now) |
182 | PUSHs (sv_2mortal (newSViv (ttl))); |
347 | retval = now; |
183 | |
|
|
184 | for (i = 0; i < count; ++i) |
|
|
185 | switch (type) |
|
|
186 | { |
|
|
187 | case DNS_IPv6_AAAA: |
|
|
188 | PUSHs (sv_2mortal (newSVpvn (i * 16 + (char *)addresses, 16))); |
|
|
189 | break; |
|
|
190 | case DNS_IPv4_A: |
|
|
191 | PUSHs (sv_2mortal (newSVpvn (i * 4 + (char *)addresses, 4))); |
|
|
192 | break; |
|
|
193 | case DNS_PTR: |
|
|
194 | PUSHs (sv_2mortal (newSVpv (*(char **)addresses, 0))); |
|
|
195 | break; |
|
|
196 | } |
|
|
197 | } |
348 | } |
198 | |
349 | else |
199 | PUTBACK; |
350 | retval = now; |
200 | call_sv (sv_2mortal (cb), G_DISCARD | G_VOID | G_EVAL); |
|
|
201 | |
351 | |
202 | FREETMPS; |
352 | FREETMPS; |
203 | |
|
|
204 | if (SvTRUE (ERRSV)) |
|
|
205 | { |
|
|
206 | PUSHMARK (SP); |
|
|
207 | PUTBACK; |
|
|
208 | call_sv (get_sv ("EV::DIED", 1), G_DISCARD | G_VOID | G_EVAL | G_KEEPERR); |
|
|
209 | } |
|
|
210 | |
|
|
211 | LEAVE; |
353 | LEAVE; |
|
|
354 | |
|
|
355 | return retval; |
212 | } |
356 | } |
213 | #endif |
|
|
214 | |
357 | |
215 | #define CHECK_REPEAT(repeat) if (repeat < 0.) \ |
358 | #define CHECK_REPEAT(repeat) if (repeat < 0.) \ |
216 | croak (# repeat " value must be >= 0"); |
359 | croak (# repeat " value must be >= 0"); |
217 | |
360 | |
218 | #define CHECK_FD(fh,fd) if ((fd) < 0) \ |
361 | #define CHECK_FD(fh,fd) if ((fd) < 0) \ |
219 | croak ("illegal file descriptor or filehandle (either no attached file descriptor or illegal value): %s", SvPV_nolen (fh)); |
362 | croak ("illegal file descriptor or filehandle (either no attached file descriptor or illegal value): %s", SvPV_nolen (fh)); |
220 | |
363 | |
|
|
364 | #define CHECK_SIG(sv,num) if ((num) < 0) \ |
|
|
365 | croak ("illegal signal number or name: %s", SvPV_nolen (sv)); |
|
|
366 | |
|
|
367 | static void |
|
|
368 | default_fork (void) |
|
|
369 | { |
|
|
370 | ev_loop_fork (EV_DEFAULT_UC); |
|
|
371 | } |
|
|
372 | |
221 | ///////////////////////////////////////////////////////////////////////////// |
373 | ///////////////////////////////////////////////////////////////////////////// |
222 | // XS interface functions |
374 | // XS interface functions |
223 | |
375 | |
224 | MODULE = EV PACKAGE = EV PREFIX = ev_ |
376 | MODULE = EV PACKAGE = EV PREFIX = ev_ |
225 | |
377 | |
226 | PROTOTYPES: ENABLE |
378 | PROTOTYPES: ENABLE |
227 | |
379 | |
228 | BOOT: |
380 | BOOT: |
229 | { |
381 | { |
230 | int i; |
|
|
231 | HV *stash = gv_stashpv ("EV", 1); |
382 | HV *stash = gv_stashpv ("EV", 1); |
232 | |
383 | |
233 | static const struct { |
384 | static const struct { |
234 | const char *name; |
385 | const char *name; |
235 | IV iv; |
386 | IV iv; |
236 | } *civ, const_iv[] = { |
387 | } *civ, const_iv[] = { |
237 | # define const_iv(pfx, name) { # name, (IV) pfx ## name }, |
388 | # define const_iv(pfx, name) { # name, (IV) pfx ## name }, |
|
|
389 | const_iv (EV_, MINPRI) |
|
|
390 | const_iv (EV_, MAXPRI) |
|
|
391 | |
238 | const_iv (EV_, UNDEF) |
392 | const_iv (EV_, UNDEF) |
239 | const_iv (EV_, NONE) |
393 | const_iv (EV_, NONE) |
240 | const_iv (EV_, TIMEOUT) |
|
|
241 | const_iv (EV_, READ) |
394 | const_iv (EV_, READ) |
242 | const_iv (EV_, WRITE) |
395 | const_iv (EV_, WRITE) |
|
|
396 | const_iv (EV_, IO) |
|
|
397 | const_iv (EV_, TIMER) |
|
|
398 | const_iv (EV_, PERIODIC) |
243 | const_iv (EV_, SIGNAL) |
399 | const_iv (EV_, SIGNAL) |
|
|
400 | const_iv (EV_, CHILD) |
|
|
401 | const_iv (EV_, STAT) |
244 | const_iv (EV_, IDLE) |
402 | const_iv (EV_, IDLE) |
|
|
403 | const_iv (EV_, PREPARE) |
|
|
404 | /*const_iv (EV_, CHECK) needs special tretament */ |
|
|
405 | const_iv (EV_, EMBED) |
245 | const_iv (EV_, CHECK) |
406 | const_iv (EV_, FORK) |
|
|
407 | const_iv (EV_, CLEANUP) |
|
|
408 | const_iv (EV_, ASYNC) |
|
|
409 | const_iv (EV_, CUSTOM) |
246 | const_iv (EV_, ERROR) |
410 | const_iv (EV_, ERROR) |
247 | |
411 | |
|
|
412 | const_iv (EV, RUN_NOWAIT) |
|
|
413 | const_iv (EV, RUN_ONCE) |
|
|
414 | |
|
|
415 | const_iv (EV, BREAK_CANCEL) |
|
|
416 | const_iv (EV, BREAK_ONE) |
|
|
417 | const_iv (EV, BREAK_ALL) |
|
|
418 | const_iv (EV, BACKEND_SELECT) |
|
|
419 | const_iv (EV, BACKEND_POLL) |
|
|
420 | const_iv (EV, BACKEND_EPOLL) |
|
|
421 | const_iv (EV, BACKEND_KQUEUE) |
|
|
422 | const_iv (EV, BACKEND_DEVPOLL) |
|
|
423 | const_iv (EV, BACKEND_PORT) |
|
|
424 | const_iv (EV, BACKEND_ALL) |
|
|
425 | const_iv (EV, BACKEND_MASK) |
|
|
426 | const_iv (EV, FLAG_AUTO) |
|
|
427 | const_iv (EV, FLAG_FORKCHECK) |
|
|
428 | const_iv (EV, FLAG_SIGNALFD) |
|
|
429 | const_iv (EV, FLAG_NOSIGMASK) |
|
|
430 | const_iv (EV, FLAG_NOENV) |
|
|
431 | const_iv (EV, FLAG_NOINOTIFY) |
|
|
432 | |
|
|
433 | const_iv (EV_, VERSION_MAJOR) |
|
|
434 | const_iv (EV_, VERSION_MINOR) |
|
|
435 | #if EV_COMPAT3 |
|
|
436 | const_iv (EV, FLAG_NOSIGFD) /* compatibility, always 0 */ |
|
|
437 | const_iv (EV_, TIMEOUT) |
|
|
438 | const_iv (EV, LOOP_NONBLOCK) |
248 | const_iv (EV, LOOP_ONESHOT) |
439 | const_iv (EV, LOOP_ONESHOT) |
|
|
440 | const_iv (EV, UNLOOP_CANCEL) |
249 | const_iv (EV, LOOP_NONBLOCK) |
441 | const_iv (EV, UNLOOP_ONE) |
250 | |
|
|
251 | const_iv (EV, METHOD_NONE) |
|
|
252 | const_iv (EV, METHOD_SELECT) |
|
|
253 | const_iv (EV, METHOD_EPOLL) |
442 | const_iv (EV, UNLOOP_ALL) |
|
|
443 | #endif |
254 | }; |
444 | }; |
255 | |
445 | |
256 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
446 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ > const_iv; civ--) |
257 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
447 | newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv)); |
258 | |
448 | |
|
|
449 | /* since this clashes with perl CHECK blocks, */ |
|
|
450 | /* but we are interested in constants, */ |
|
|
451 | /* and not blocks, we treat CHECK specially. */ |
|
|
452 | { |
|
|
453 | /* the local $^W = 0 takes care of the warning */ |
|
|
454 | CV *cv = newCONSTSUB (stash, "CHECK", newSViv (EV_CHECK)); |
|
|
455 | /* now we need to re-set the gv, in case it was hijacked */ |
|
|
456 | GvCV_set (gv_fetchpv ("EV::CHECK", GV_ADD, SVt_PVCV), cv); |
|
|
457 | } |
|
|
458 | |
|
|
459 | stash_loop = gv_stashpv ("EV::Loop" , 1); |
259 | stash_watcher = gv_stashpv ("EV::Watcher" , 1); |
460 | stash_watcher = gv_stashpv ("EV::Watcher" , 1); |
260 | stash_io = gv_stashpv ("EV::Io" , 1); |
461 | stash_io = gv_stashpv ("EV::IO" , 1); |
261 | stash_timer = gv_stashpv ("EV::Timer" , 1); |
462 | stash_timer = gv_stashpv ("EV::Timer" , 1); |
262 | stash_periodic = gv_stashpv ("EV::Periodic", 1); |
463 | stash_periodic = gv_stashpv ("EV::Periodic", 1); |
263 | stash_signal = gv_stashpv ("EV::Signal" , 1); |
464 | stash_signal = gv_stashpv ("EV::Signal" , 1); |
264 | stash_idle = gv_stashpv ("EV::Idle" , 1); |
465 | stash_idle = gv_stashpv ("EV::Idle" , 1); |
265 | stash_prepare = gv_stashpv ("EV::Prepare" , 1); |
466 | stash_prepare = gv_stashpv ("EV::Prepare" , 1); |
266 | stash_check = gv_stashpv ("EV::Check" , 1); |
467 | stash_check = gv_stashpv ("EV::Check" , 1); |
267 | stash_child = gv_stashpv ("EV::Child" , 1); |
468 | stash_child = gv_stashpv ("EV::Child" , 1); |
|
|
469 | stash_embed = gv_stashpv ("EV::Embed" , 1); |
|
|
470 | stash_stat = gv_stashpv ("EV::Stat" , 1); |
|
|
471 | stash_fork = gv_stashpv ("EV::Fork" , 1); |
|
|
472 | stash_cleanup = gv_stashpv ("EV::Cleanup" , 1); |
|
|
473 | stash_async = gv_stashpv ("EV::Async" , 1); |
268 | |
474 | |
269 | { |
475 | { |
270 | SV *sv = perl_get_sv ("EV::API", TRUE); |
476 | SV *sv = perl_get_sv ("EV::API", TRUE); |
271 | perl_get_sv ("EV::API", TRUE); /* silence 5.10 warning */ |
477 | perl_get_sv ("EV::API", TRUE); /* silence 5.10 warning */ |
272 | |
478 | |
273 | /* the poor man's shared library emulator */ |
479 | /* the poor man's shared library emulator */ |
274 | evapi.ver = EV_API_VERSION; |
480 | evapi.ver = EV_API_VERSION; |
275 | evapi.rev = EV_API_REVISION; |
481 | evapi.rev = EV_API_REVISION; |
276 | evapi.sv_fileno = sv_fileno; |
482 | evapi.sv_fileno = sv_fileno; |
277 | evapi.sv_signum = sv_signum; |
483 | evapi.sv_signum = s_signum; |
278 | evapi.now = &ev_now; |
484 | evapi.supported_backends = ev_supported_backends (); |
279 | evapi.method = &ev_method; |
485 | evapi.recommended_backends = ev_recommended_backends (); |
280 | evapi.loop_done = &ev_loop_done; |
486 | evapi.embeddable_backends = ev_embeddable_backends (); |
281 | evapi.time = ev_time; |
487 | evapi.time_ = ev_time; |
|
|
488 | evapi.sleep_ = ev_sleep; |
282 | evapi.loop = ev_loop; |
489 | evapi.loop_new = ev_loop_new; |
|
|
490 | evapi.loop_destroy = ev_loop_destroy; |
|
|
491 | evapi.loop_fork = ev_loop_fork; |
|
|
492 | evapi.iteration = ev_iteration; |
|
|
493 | evapi.depth = ev_depth; |
|
|
494 | evapi.set_userdata = ev_set_userdata; |
|
|
495 | evapi.userdata = ev_userdata; |
|
|
496 | evapi.now = ev_now; |
|
|
497 | evapi.now_update = ev_now_update; |
|
|
498 | evapi.suspend = ev_suspend; |
|
|
499 | evapi.resume = ev_resume; |
|
|
500 | evapi.backend = ev_backend; |
|
|
501 | evapi.break_ = ev_break; |
|
|
502 | evapi.invoke_pending = ev_invoke_pending; |
|
|
503 | evapi.pending_count = ev_pending_count; |
|
|
504 | evapi.verify = ev_verify; |
|
|
505 | evapi.set_loop_release_cb = ev_set_loop_release_cb; |
|
|
506 | evapi.set_invoke_pending_cb= ev_set_invoke_pending_cb; |
|
|
507 | evapi.ref = ev_ref; |
|
|
508 | evapi.unref = ev_unref; |
|
|
509 | evapi.run = ev_run; |
283 | evapi.once = ev_once; |
510 | evapi.once = ev_once; |
284 | evapi.io_start = ev_io_start; |
511 | evapi.io_start = ev_io_start; |
285 | evapi.io_stop = ev_io_stop; |
512 | evapi.io_stop = ev_io_stop; |
286 | evapi.timer_start = ev_timer_start; |
513 | evapi.timer_start = ev_timer_start; |
287 | evapi.timer_stop = ev_timer_stop; |
514 | evapi.timer_stop = ev_timer_stop; |
288 | evapi.timer_again = ev_timer_again; |
515 | evapi.timer_again = ev_timer_again; |
|
|
516 | evapi.timer_remaining = ev_timer_remaining; |
289 | evapi.periodic_start = ev_periodic_start; |
517 | evapi.periodic_start = ev_periodic_start; |
290 | evapi.periodic_stop = ev_periodic_stop; |
518 | evapi.periodic_stop = ev_periodic_stop; |
291 | evapi.signal_start = ev_signal_start; |
519 | evapi.signal_start = ev_signal_start; |
292 | evapi.signal_stop = ev_signal_stop; |
520 | evapi.signal_stop = ev_signal_stop; |
293 | evapi.idle_start = ev_idle_start; |
521 | evapi.idle_start = ev_idle_start; |
294 | evapi.idle_stop = ev_idle_stop; |
522 | evapi.idle_stop = ev_idle_stop; |
295 | evapi.prepare_start = ev_prepare_start; |
523 | evapi.prepare_start = ev_prepare_start; |
296 | evapi.prepare_stop = ev_prepare_stop; |
524 | evapi.prepare_stop = ev_prepare_stop; |
297 | evapi.check_start = ev_check_start; |
525 | evapi.check_start = ev_check_start; |
298 | evapi.check_stop = ev_check_stop; |
526 | evapi.check_stop = ev_check_stop; |
|
|
527 | #if EV_CHILD_ENABLE |
299 | evapi.child_start = ev_child_start; |
528 | evapi.child_start = ev_child_start; |
300 | evapi.child_stop = ev_child_stop; |
529 | evapi.child_stop = ev_child_stop; |
|
|
530 | #endif |
|
|
531 | evapi.stat_start = ev_stat_start; |
|
|
532 | evapi.stat_stop = ev_stat_stop; |
|
|
533 | evapi.stat_stat = ev_stat_stat; |
|
|
534 | evapi.embed_start = ev_embed_start; |
|
|
535 | evapi.embed_stop = ev_embed_stop; |
|
|
536 | evapi.embed_sweep = ev_embed_sweep; |
|
|
537 | evapi.fork_start = ev_fork_start; |
|
|
538 | evapi.fork_stop = ev_fork_stop; |
|
|
539 | evapi.cleanup_start = ev_cleanup_start; |
|
|
540 | evapi.cleanup_stop = ev_cleanup_stop; |
|
|
541 | evapi.async_start = ev_async_start; |
|
|
542 | evapi.async_stop = ev_async_stop; |
|
|
543 | evapi.async_send = ev_async_send; |
|
|
544 | evapi.clear_pending = ev_clear_pending; |
|
|
545 | evapi.invoke = ev_invoke; |
301 | |
546 | |
302 | sv_setiv (sv, (IV)&evapi); |
547 | sv_setiv (sv, (IV)&evapi); |
303 | SvREADONLY_on (sv); |
548 | SvREADONLY_on (sv); |
304 | } |
549 | } |
|
|
550 | #if !defined _WIN32 && !defined _MINIX |
|
|
551 | #if __linux |
|
|
552 | int __register_atfork(void (*prepare) (void), void (*parent) (void), void (*child) (void), void * __dso_handle); |
|
|
553 | __register_atfork (0, 0, default_fork, 0); |
|
|
554 | #else |
|
|
555 | pthread_atfork (0, 0, default_fork); |
|
|
556 | #endif |
|
|
557 | #endif |
|
|
558 | } |
305 | |
559 | |
306 | pthread_atfork (ev_fork_prepare, ev_fork_parent, ev_fork_child); |
560 | SV *ev_default_loop (unsigned int flags = 0) |
|
|
561 | CODE: |
|
|
562 | { |
|
|
563 | if (!default_loop_sv) |
|
|
564 | { |
|
|
565 | evapi.default_loop = ev_default_loop (flags); |
|
|
566 | |
|
|
567 | if (!evapi.default_loop) |
|
|
568 | XSRETURN_UNDEF; |
|
|
569 | |
|
|
570 | default_loop_sv = sv_bless (newRV_noinc (newSViv (PTR2IV (evapi.default_loop))), stash_loop); |
|
|
571 | } |
|
|
572 | |
|
|
573 | RETVAL = newSVsv (default_loop_sv); |
|
|
574 | } |
|
|
575 | OUTPUT: |
|
|
576 | RETVAL |
|
|
577 | |
|
|
578 | void ev_default_destroy () |
|
|
579 | CODE: |
|
|
580 | ev_loop_destroy (EV_DEFAULT_UC); |
|
|
581 | SvREFCNT_dec (default_loop_sv); |
|
|
582 | default_loop_sv = 0; |
|
|
583 | |
|
|
584 | unsigned int ev_supported_backends () |
|
|
585 | |
|
|
586 | unsigned int ev_recommended_backends () |
|
|
587 | |
|
|
588 | unsigned int ev_embeddable_backends () |
|
|
589 | |
|
|
590 | void ev_sleep (NV interval) |
|
|
591 | |
|
|
592 | NV ev_time () |
|
|
593 | |
|
|
594 | void ev_feed_signal (SV *signal) |
|
|
595 | CODE: |
|
|
596 | { |
|
|
597 | Signal signum = s_signum (signal); |
|
|
598 | CHECK_SIG (signal, signum); |
|
|
599 | |
|
|
600 | ev_feed_signal (signum); |
307 | } |
601 | } |
308 | |
602 | |
309 | NV ev_now () |
603 | NV ev_now () |
310 | CODE: |
604 | C_ARGS: evapi.default_loop |
311 | RETVAL = ev_now; |
|
|
312 | OUTPUT: |
|
|
313 | RETVAL |
|
|
314 | |
605 | |
315 | int ev_method () |
606 | void ev_now_update () |
316 | CODE: |
607 | C_ARGS: evapi.default_loop |
317 | RETVAL = ev_method; |
|
|
318 | OUTPUT: |
|
|
319 | RETVAL |
|
|
320 | |
608 | |
321 | NV ev_time () |
609 | void ev_suspend () |
|
|
610 | C_ARGS: evapi.default_loop |
322 | |
611 | |
|
|
612 | void ev_resume () |
|
|
613 | C_ARGS: evapi.default_loop |
|
|
614 | |
|
|
615 | unsigned int ev_backend () |
|
|
616 | C_ARGS: evapi.default_loop |
|
|
617 | |
|
|
618 | void ev_verify () |
|
|
619 | ALIAS: |
|
|
620 | loop_verify = 1 |
|
|
621 | C_ARGS: evapi.default_loop |
|
|
622 | |
|
|
623 | unsigned int ev_iteration () |
|
|
624 | ALIAS: |
|
|
625 | loop_count = 1 |
|
|
626 | C_ARGS: evapi.default_loop |
|
|
627 | |
|
|
628 | unsigned int ev_depth () |
|
|
629 | ALIAS: |
|
|
630 | loop_depth = 1 |
|
|
631 | C_ARGS: evapi.default_loop |
|
|
632 | |
|
|
633 | void ev_set_io_collect_interval (NV interval) |
|
|
634 | C_ARGS: evapi.default_loop, interval |
|
|
635 | |
|
|
636 | void ev_set_timeout_collect_interval (NV interval) |
|
|
637 | C_ARGS: evapi.default_loop, interval |
|
|
638 | |
323 | void ev_init (int flags = 0) |
639 | int ev_run (int flags = 0) |
|
|
640 | ALIAS: |
|
|
641 | loop = 1 |
|
|
642 | C_ARGS: evapi.default_loop, flags |
324 | |
643 | |
325 | void ev_loop (int flags = 0) |
644 | void ev_break (int how = EVBREAK_ONE) |
|
|
645 | ALIAS: |
|
|
646 | unloop = 1 |
|
|
647 | C_ARGS: evapi.default_loop, how |
326 | |
648 | |
327 | void ev_loop_done (int value = 1) |
649 | void ev_feed_fd_event (int fd, int revents = EV_NONE) |
328 | CODE: |
650 | C_ARGS: evapi.default_loop, fd, revents |
329 | ev_loop_done = value; |
|
|
330 | |
651 | |
|
|
652 | void ev_feed_signal_event (SV *signal) |
|
|
653 | CODE: |
|
|
654 | { |
|
|
655 | Signal signum = s_signum (signal); |
|
|
656 | CHECK_SIG (signal, signum); |
|
|
657 | |
|
|
658 | ev_feed_signal_event (evapi.default_loop, signum); |
|
|
659 | } |
|
|
660 | |
|
|
661 | unsigned int ev_pending_count () |
|
|
662 | C_ARGS: evapi.default_loop |
|
|
663 | |
|
|
664 | void ev_invoke_pending () |
|
|
665 | C_ARGS: evapi.default_loop |
|
|
666 | |
331 | struct ev_io *io (SV *fh, int events, SV *cb) |
667 | ev_io *io (SV *fh, int events, SV *cb) |
332 | ALIAS: |
668 | ALIAS: |
333 | io_ns = 1 |
669 | io_ns = 1 |
|
|
670 | _ae_io = 2 |
334 | CODE: |
671 | CODE: |
335 | { |
672 | { |
336 | int fd = sv_fileno (fh); |
673 | int fd = s_fileno (fh, events & EV_WRITE); |
337 | CHECK_FD (fh, fd); |
674 | CHECK_FD (fh, fd); |
338 | |
|
|
339 | RETVAL = e_new (sizeof (struct ev_io), cb); |
675 | RETVAL = e_new (sizeof (ev_io), cb, default_loop_sv); |
340 | RETVAL->fh = newSVsv (fh); |
676 | e_fh (RETVAL) = newSVsv (fh); |
|
|
677 | |
|
|
678 | if (ix == 2) |
|
|
679 | { |
|
|
680 | events = events ? EV_WRITE : EV_READ; |
|
|
681 | e_flags (RETVAL) |= WFLAG_NOARGS; |
|
|
682 | } |
|
|
683 | |
341 | ev_io_set (RETVAL, fd, events); |
684 | ev_io_set (RETVAL, fd, events); |
342 | if (!ix) ev_io_start (RETVAL); |
685 | if (ix != 1) START (io, RETVAL); |
343 | } |
686 | } |
344 | OUTPUT: |
687 | OUTPUT: |
345 | RETVAL |
688 | RETVAL |
346 | |
689 | |
347 | struct ev_timer *timer (NV after, NV repeat, SV *cb) |
690 | ev_timer *timer (NV after, NV repeat, SV *cb) |
348 | ALIAS: |
691 | ALIAS: |
349 | timer_ns = 1 |
692 | timer_ns = 1 |
350 | INIT: |
693 | INIT: |
351 | CHECK_REPEAT (repeat); |
694 | CHECK_REPEAT (repeat); |
352 | CODE: |
695 | CODE: |
353 | RETVAL = e_new (sizeof (struct ev_timer), cb); |
696 | RETVAL = e_new (sizeof (ev_timer), cb, default_loop_sv); |
354 | ev_timer_set (RETVAL, after, repeat); |
697 | ev_timer_set (RETVAL, after, repeat); |
355 | if (!ix) ev_timer_start (RETVAL); |
698 | if (!ix) START (timer, RETVAL); |
356 | OUTPUT: |
699 | OUTPUT: |
357 | RETVAL |
700 | RETVAL |
358 | |
701 | |
359 | struct ev_periodic *periodic (NV at, NV interval, SV *cb) |
702 | SV *periodic (NV at, NV interval, SV *reschedule_cb, SV *cb) |
360 | ALIAS: |
703 | ALIAS: |
361 | periodic_ns = 1 |
704 | periodic_ns = 1 |
362 | INIT: |
705 | INIT: |
363 | CHECK_REPEAT (interval); |
706 | CHECK_REPEAT (interval); |
364 | CODE: |
707 | CODE: |
365 | RETVAL = e_new (sizeof (struct ev_periodic), cb); |
708 | { |
366 | ev_periodic_set (RETVAL, at, interval); |
709 | ev_periodic *w; |
367 | if (!ix) ev_periodic_start (RETVAL); |
710 | w = e_new (sizeof (ev_periodic), cb, default_loop_sv); |
|
|
711 | e_fh (w) = SvTRUE (reschedule_cb) ? newSVsv (reschedule_cb) : 0; |
|
|
712 | ev_periodic_set (w, at, interval, e_fh (w) ? e_periodic_cb : 0); |
|
|
713 | RETVAL = e_bless ((ev_watcher *)w, stash_periodic); |
|
|
714 | if (!ix) START (periodic, w); |
|
|
715 | } |
368 | OUTPUT: |
716 | OUTPUT: |
369 | RETVAL |
717 | RETVAL |
370 | |
718 | |
371 | struct ev_signal *signal (Signal signum, SV *cb) |
719 | ev_signal *signal (SV *signal, SV *cb) |
372 | ALIAS: |
720 | ALIAS: |
373 | signal_ns = 1 |
721 | signal_ns = 1 |
374 | CODE: |
722 | CODE: |
|
|
723 | { |
|
|
724 | Signal signum = s_signum (signal); |
|
|
725 | CHECK_SIG (signal, signum); |
|
|
726 | |
375 | RETVAL = e_new (sizeof (struct ev_signal), cb); |
727 | RETVAL = e_new (sizeof (ev_signal), cb, default_loop_sv); |
376 | ev_signal_set (RETVAL, signum); |
728 | ev_signal_set (RETVAL, signum); |
377 | if (!ix) ev_signal_start (RETVAL); |
729 | if (!ix) START_SIGNAL (RETVAL); |
|
|
730 | } |
378 | OUTPUT: |
731 | OUTPUT: |
379 | RETVAL |
732 | RETVAL |
380 | |
733 | |
381 | struct ev_idle *idle (SV *cb) |
734 | ev_idle *idle (SV *cb) |
382 | ALIAS: |
735 | ALIAS: |
383 | idle_ns = 1 |
736 | idle_ns = 1 |
384 | CODE: |
737 | CODE: |
385 | RETVAL = e_new (sizeof (struct ev_idle), cb); |
738 | RETVAL = e_new (sizeof (ev_idle), cb, default_loop_sv); |
386 | ev_idle_set (RETVAL); |
739 | ev_idle_set (RETVAL); |
387 | if (!ix) ev_idle_start (RETVAL); |
740 | if (!ix) START (idle, RETVAL); |
388 | OUTPUT: |
741 | OUTPUT: |
389 | RETVAL |
742 | RETVAL |
390 | |
743 | |
391 | struct ev_prepare *prepare (SV *cb) |
744 | ev_prepare *prepare (SV *cb) |
392 | ALIAS: |
745 | ALIAS: |
393 | prepare_ns = 1 |
746 | prepare_ns = 1 |
394 | CODE: |
747 | CODE: |
395 | RETVAL = e_new (sizeof (struct ev_prepare), cb); |
748 | RETVAL = e_new (sizeof (ev_prepare), cb, default_loop_sv); |
396 | ev_prepare_set (RETVAL); |
749 | ev_prepare_set (RETVAL); |
397 | if (!ix) ev_prepare_start (RETVAL); |
750 | if (!ix) START (prepare, RETVAL); |
398 | OUTPUT: |
751 | OUTPUT: |
399 | RETVAL |
752 | RETVAL |
400 | |
753 | |
401 | struct ev_check *check (SV *cb) |
754 | ev_check *check (SV *cb) |
402 | ALIAS: |
755 | ALIAS: |
403 | check_ns = 1 |
756 | check_ns = 1 |
404 | CODE: |
757 | CODE: |
405 | RETVAL = e_new (sizeof (struct ev_check), cb); |
758 | RETVAL = e_new (sizeof (ev_check), cb, default_loop_sv); |
406 | ev_check_set (RETVAL); |
759 | ev_check_set (RETVAL); |
407 | if (!ix) ev_check_start (RETVAL); |
760 | if (!ix) START (check, RETVAL); |
408 | OUTPUT: |
761 | OUTPUT: |
409 | RETVAL |
762 | RETVAL |
410 | |
763 | |
|
|
764 | ev_fork *fork (SV *cb) |
|
|
765 | ALIAS: |
|
|
766 | fork_ns = 1 |
|
|
767 | CODE: |
|
|
768 | RETVAL = e_new (sizeof (ev_fork), cb, default_loop_sv); |
|
|
769 | ev_fork_set (RETVAL); |
|
|
770 | if (!ix) START (fork, RETVAL); |
|
|
771 | OUTPUT: |
|
|
772 | RETVAL |
|
|
773 | |
|
|
774 | #if CLEANUP_ENABLED |
|
|
775 | |
|
|
776 | ev_cleanup *cleanup (SV *cb) |
|
|
777 | ALIAS: |
|
|
778 | cleanup_ns = 1 |
|
|
779 | CODE: |
|
|
780 | RETVAL = e_new (sizeof (ev_cleanup), cb, default_loop_sv); |
|
|
781 | SvREFCNT_dec (RETVAL->loop); /* must not keep loop object alive */ |
|
|
782 | ev_cleanup_set (RETVAL); |
|
|
783 | if (!ix) START (cleanup, RETVAL); |
|
|
784 | OUTPUT: |
|
|
785 | RETVAL |
|
|
786 | |
|
|
787 | #endif |
|
|
788 | |
411 | struct ev_child *child (int pid, SV *cb) |
789 | ev_child *child (int pid, int trace, SV *cb) |
412 | ALIAS: |
790 | ALIAS: |
413 | check_ns = 1 |
791 | child_ns = 1 |
414 | CODE: |
792 | CODE: |
415 | RETVAL = e_new (sizeof (struct ev_check), cb); |
793 | #if EV_CHILD_ENABLE |
|
|
794 | RETVAL = e_new (sizeof (ev_child), cb, default_loop_sv); |
416 | ev_child_set (RETVAL, pid); |
795 | ev_child_set (RETVAL, pid, trace); |
417 | if (!ix) ev_child_start (RETVAL); |
796 | if (!ix) START (child, RETVAL); |
|
|
797 | #else |
|
|
798 | croak ("EV::child watchers not supported on this platform"); |
|
|
799 | #endif |
418 | OUTPUT: |
800 | OUTPUT: |
419 | RETVAL |
801 | RETVAL |
420 | |
802 | |
|
|
803 | |
|
|
804 | ev_stat *stat (SV *path, NV interval, SV *cb) |
|
|
805 | ALIAS: |
|
|
806 | stat_ns = 1 |
|
|
807 | CODE: |
|
|
808 | RETVAL = e_new (sizeof (ev_stat), cb, default_loop_sv); |
|
|
809 | e_fh (RETVAL) = newSVsv (path); |
|
|
810 | ev_stat_set (RETVAL, SvPVbyte_nolen (e_fh (RETVAL)), interval); |
|
|
811 | if (!ix) START (stat, RETVAL); |
|
|
812 | OUTPUT: |
|
|
813 | RETVAL |
|
|
814 | |
|
|
815 | #ifndef EV_NO_LOOPS |
|
|
816 | |
|
|
817 | ev_embed *embed (struct ev_loop *loop, SV *cb = 0) |
|
|
818 | ALIAS: |
|
|
819 | embed_ns = 1 |
|
|
820 | CODE: |
|
|
821 | { |
|
|
822 | if (!(ev_backend (loop) & ev_embeddable_backends ())) |
|
|
823 | croak ("passed loop is not embeddable via EV::embed,"); |
|
|
824 | |
|
|
825 | RETVAL = e_new (sizeof (ev_embed), cb, default_loop_sv); |
|
|
826 | e_fh (RETVAL) = newSVsv (ST (0)); |
|
|
827 | ev_embed_set (RETVAL, loop); |
|
|
828 | if (!ix) START (embed, RETVAL); |
|
|
829 | } |
|
|
830 | OUTPUT: |
|
|
831 | RETVAL |
|
|
832 | |
|
|
833 | #endif |
|
|
834 | |
|
|
835 | ev_async *async (SV *cb) |
|
|
836 | ALIAS: |
|
|
837 | async_ns = 1 |
|
|
838 | CODE: |
|
|
839 | RETVAL = e_new (sizeof (ev_async), cb, default_loop_sv); |
|
|
840 | ev_async_set (RETVAL); |
|
|
841 | if (!ix) START (async, RETVAL); |
|
|
842 | OUTPUT: |
|
|
843 | RETVAL |
|
|
844 | |
|
|
845 | void once (SV *fh, int events, SV *timeout, SV *cb) |
|
|
846 | CODE: |
|
|
847 | ev_once ( |
|
|
848 | evapi.default_loop, |
|
|
849 | s_fileno (fh, events & EV_WRITE), events, |
|
|
850 | SvOK (timeout) ? SvNV (timeout) : -1., |
|
|
851 | e_once_cb, |
|
|
852 | newSVsv (cb) |
|
|
853 | ); |
421 | |
854 | |
422 | PROTOTYPES: DISABLE |
855 | PROTOTYPES: DISABLE |
423 | |
856 | |
424 | MODULE = EV PACKAGE = EV::Watcher PREFIX = ev_ |
857 | MODULE = EV PACKAGE = EV::Watcher PREFIX = ev_ |
425 | |
858 | |
426 | int ev_is_active (struct ev_watcher *w) |
859 | int ev_is_active (ev_watcher *w) |
427 | |
860 | |
|
|
861 | int ev_is_pending (ev_watcher *w) |
|
|
862 | |
|
|
863 | void ev_invoke (ev_watcher *w, int revents = EV_NONE) |
|
|
864 | C_ARGS: e_loop (w), w, revents |
|
|
865 | |
|
|
866 | int ev_clear_pending (ev_watcher *w) |
|
|
867 | C_ARGS: e_loop (w), w |
|
|
868 | |
|
|
869 | void ev_feed_event (ev_watcher *w, int revents = EV_NONE) |
|
|
870 | C_ARGS: e_loop (w), w, revents |
|
|
871 | |
|
|
872 | int keepalive (ev_watcher *w, int new_value = 0) |
|
|
873 | CODE: |
|
|
874 | { |
|
|
875 | RETVAL = w->e_flags & WFLAG_KEEPALIVE; |
|
|
876 | new_value = new_value ? WFLAG_KEEPALIVE : 0; |
|
|
877 | |
|
|
878 | if (items > 1 && ((new_value ^ w->e_flags) & WFLAG_KEEPALIVE)) |
|
|
879 | { |
|
|
880 | w->e_flags = (w->e_flags & ~WFLAG_KEEPALIVE) | new_value; |
|
|
881 | REF (w); |
|
|
882 | UNREF (w); |
|
|
883 | } |
|
|
884 | } |
|
|
885 | OUTPUT: |
|
|
886 | RETVAL |
|
|
887 | |
428 | SV *cb (struct ev_watcher *w, SV *new_cb = 0) |
888 | SV *cb (ev_watcher *w, SV *new_cb = 0) |
429 | CODE: |
889 | CODE: |
430 | { |
890 | { |
431 | RETVAL = newSVsv (w->cb_sv); |
|
|
432 | |
|
|
433 | if (items > 1) |
|
|
434 | sv_setsv (w->cb_sv, new_cb); |
|
|
435 | } |
|
|
436 | OUTPUT: |
|
|
437 | RETVAL |
|
|
438 | |
|
|
439 | void trigger (struct ev_watcher *w, int revents = EV_NONE) |
|
|
440 | CODE: |
|
|
441 | w->cb (w, revents); |
|
|
442 | |
|
|
443 | MODULE = EV PACKAGE = EV::Io PREFIX = ev_io_ |
|
|
444 | |
|
|
445 | void ev_io_start (struct ev_io *w) |
|
|
446 | |
|
|
447 | void ev_io_stop (struct ev_io *w) |
|
|
448 | |
|
|
449 | void DESTROY (struct ev_io *w) |
|
|
450 | CODE: |
|
|
451 | ev_io_stop (w); |
|
|
452 | e_destroy (w); |
|
|
453 | |
|
|
454 | void set (struct ev_io *w, SV *fh, int events) |
|
|
455 | CODE: |
|
|
456 | { |
|
|
457 | int active = w->active; |
|
|
458 | int fd = sv_fileno (fh); |
|
|
459 | CHECK_FD (fh, fd); |
|
|
460 | |
|
|
461 | if (active) ev_io_stop (w); |
|
|
462 | |
|
|
463 | sv_setsv (w->fh, fh); |
|
|
464 | ev_io_set (w, fd, events); |
|
|
465 | |
|
|
466 | if (active) ev_io_start (w); |
|
|
467 | } |
|
|
468 | |
|
|
469 | SV *fh (struct ev_io *w, SV *new_fh = 0) |
|
|
470 | CODE: |
|
|
471 | { |
|
|
472 | RETVAL = newSVsv (w->fh); |
|
|
473 | |
|
|
474 | if (items > 1) |
891 | if (items > 1) |
475 | { |
892 | { |
476 | int active = w->active; |
893 | new_cb = s_get_cv_croak (new_cb); |
477 | if (active) ev_io_stop (w); |
894 | RETVAL = newRV_noinc (w->cb_sv); |
478 | |
895 | w->cb_sv = SvREFCNT_inc (new_cb); |
479 | sv_setsv (w->fh, new_fh); |
|
|
480 | ev_io_set (w, sv_fileno (w->fh), w->events); |
|
|
481 | |
|
|
482 | if (active) ev_io_start (w); |
|
|
483 | } |
896 | } |
|
|
897 | else |
|
|
898 | RETVAL = newRV_inc (w->cb_sv); |
484 | } |
899 | } |
485 | OUTPUT: |
900 | OUTPUT: |
486 | RETVAL |
901 | RETVAL |
487 | |
902 | |
488 | short events (struct ev_io *w, short new_events = EV_UNDEF) |
903 | SV *data (ev_watcher *w, SV *new_data = 0) |
489 | CODE: |
904 | CODE: |
490 | { |
905 | { |
491 | RETVAL = w->events; |
906 | RETVAL = w->data ? newSVsv (w->data) : &PL_sv_undef; |
492 | |
907 | |
493 | if (items > 1) |
908 | if (items > 1) |
494 | { |
909 | { |
495 | int active = w->active; |
910 | SvREFCNT_dec (w->data); |
496 | if (active) ev_io_stop (w); |
911 | w->data = newSVsv (new_data); |
497 | |
|
|
498 | ev_io_set (w, w->fd, new_events); |
|
|
499 | |
|
|
500 | if (active) ev_io_start (w); |
|
|
501 | } |
912 | } |
502 | } |
913 | } |
503 | OUTPUT: |
914 | OUTPUT: |
504 | RETVAL |
915 | RETVAL |
505 | |
916 | |
|
|
917 | SV *loop (ev_watcher *w) |
|
|
918 | CODE: |
|
|
919 | RETVAL = newRV_inc (w->loop); |
|
|
920 | OUTPUT: |
|
|
921 | RETVAL |
|
|
922 | |
|
|
923 | int priority (ev_watcher *w, int new_priority = 0) |
|
|
924 | CODE: |
|
|
925 | { |
|
|
926 | RETVAL = w->priority; |
|
|
927 | |
|
|
928 | if (items > 1) |
|
|
929 | { |
|
|
930 | int active = ev_is_active (w); |
|
|
931 | |
|
|
932 | if (active) |
|
|
933 | { |
|
|
934 | /* grrr. */ |
|
|
935 | PUSHMARK (SP); |
|
|
936 | XPUSHs (ST (0)); |
|
|
937 | PUTBACK; |
|
|
938 | call_method ("stop", G_DISCARD | G_VOID); |
|
|
939 | } |
|
|
940 | |
|
|
941 | ev_set_priority (w, new_priority); |
|
|
942 | |
|
|
943 | if (active) |
|
|
944 | { |
|
|
945 | PUSHMARK (SP); |
|
|
946 | XPUSHs (ST (0)); |
|
|
947 | PUTBACK; |
|
|
948 | call_method ("start", G_DISCARD | G_VOID); |
|
|
949 | } |
|
|
950 | } |
|
|
951 | } |
|
|
952 | OUTPUT: |
|
|
953 | RETVAL |
|
|
954 | |
|
|
955 | MODULE = EV PACKAGE = EV::IO PREFIX = ev_io_ |
|
|
956 | |
|
|
957 | void ev_io_start (ev_io *w) |
|
|
958 | CODE: |
|
|
959 | START (io, w); |
|
|
960 | |
|
|
961 | void ev_io_stop (ev_io *w) |
|
|
962 | CODE: |
|
|
963 | STOP (io, w); |
|
|
964 | |
|
|
965 | void DESTROY (ev_io *w) |
|
|
966 | CODE: |
|
|
967 | STOP (io, w); |
|
|
968 | e_destroy (w); |
|
|
969 | |
|
|
970 | void set (ev_io *w, SV *fh, int events) |
|
|
971 | CODE: |
|
|
972 | { |
|
|
973 | int fd = s_fileno (fh, events & EV_WRITE); |
|
|
974 | CHECK_FD (fh, fd); |
|
|
975 | |
|
|
976 | sv_setsv (e_fh (w), fh); |
|
|
977 | RESET (io, w, (w, fd, events)); |
|
|
978 | } |
|
|
979 | |
|
|
980 | SV *fh (ev_io *w, SV *new_fh = 0) |
|
|
981 | CODE: |
|
|
982 | { |
|
|
983 | if (items > 1) |
|
|
984 | { |
|
|
985 | int fd = s_fileno (new_fh, w->events & EV_WRITE); |
|
|
986 | CHECK_FD (new_fh, fd); |
|
|
987 | |
|
|
988 | RETVAL = e_fh (w); |
|
|
989 | e_fh (w) = newSVsv (new_fh); |
|
|
990 | |
|
|
991 | RESET (io, w, (w, fd, w->events)); |
|
|
992 | } |
|
|
993 | else |
|
|
994 | RETVAL = newSVsv (e_fh (w)); |
|
|
995 | } |
|
|
996 | OUTPUT: |
|
|
997 | RETVAL |
|
|
998 | |
|
|
999 | int events (ev_io *w, int new_events = EV_UNDEF) |
|
|
1000 | CODE: |
|
|
1001 | { |
|
|
1002 | RETVAL = w->events; |
|
|
1003 | |
|
|
1004 | if (items > 1) |
|
|
1005 | RESET (io, w, (w, w->fd, new_events)); |
|
|
1006 | } |
|
|
1007 | OUTPUT: |
|
|
1008 | RETVAL |
|
|
1009 | |
506 | MODULE = EV PACKAGE = EV::Signal PREFIX = ev_signal_ |
1010 | MODULE = EV PACKAGE = EV::Signal PREFIX = ev_signal_ |
507 | |
1011 | |
508 | void ev_signal_start (struct ev_signal *w) |
1012 | void ev_signal_start (ev_signal *w) |
|
|
1013 | CODE: |
|
|
1014 | START_SIGNAL (w); |
509 | |
1015 | |
510 | void ev_signal_stop (struct ev_signal *w) |
1016 | void ev_signal_stop (ev_signal *w) |
|
|
1017 | CODE: |
|
|
1018 | STOP (signal, w); |
511 | |
1019 | |
512 | void DESTROY (struct ev_signal *w) |
1020 | void DESTROY (ev_signal *w) |
513 | CODE: |
1021 | CODE: |
514 | ev_signal_stop (w); |
1022 | STOP (signal, w); |
515 | e_destroy (w); |
1023 | e_destroy (w); |
516 | |
1024 | |
517 | void set (struct ev_signal *w, SV *signal = 0) |
1025 | void set (ev_signal *w, SV *signal) |
518 | CODE: |
1026 | CODE: |
519 | { |
1027 | { |
520 | Signal signum = sv_signum (signal); /* may croak here */ |
1028 | Signal signum = s_signum (signal); |
521 | int active = w->active; |
1029 | CHECK_SIG (signal, signum); |
522 | |
1030 | |
523 | if (active) ev_signal_stop (w); |
1031 | RESET_SIGNAL (w, (w, signum)); |
524 | ev_signal_set (w, signum); |
|
|
525 | if (active) ev_signal_start (w); |
|
|
526 | } |
1032 | } |
527 | |
1033 | |
528 | MODULE = EV PACKAGE = EV::Time |
1034 | int signal (ev_signal *w, SV *new_signal = 0) |
|
|
1035 | CODE: |
|
|
1036 | { |
|
|
1037 | RETVAL = w->signum; |
|
|
1038 | |
|
|
1039 | if (items > 1) |
|
|
1040 | { |
|
|
1041 | Signal signum = s_signum (new_signal); |
|
|
1042 | CHECK_SIG (new_signal, signum); |
|
|
1043 | |
|
|
1044 | RESET_SIGNAL (w, (w, signum)); |
|
|
1045 | } |
|
|
1046 | } |
|
|
1047 | OUTPUT: |
|
|
1048 | RETVAL |
529 | |
1049 | |
530 | MODULE = EV PACKAGE = EV::Timer PREFIX = ev_timer_ |
1050 | MODULE = EV PACKAGE = EV::Timer PREFIX = ev_timer_ |
531 | |
1051 | |
532 | void ev_timer_start (struct ev_timer *w) |
1052 | void ev_timer_start (ev_timer *w) |
533 | INIT: |
1053 | INIT: |
534 | CHECK_REPEAT (w->repeat); |
1054 | CHECK_REPEAT (w->repeat); |
|
|
1055 | CODE: |
|
|
1056 | START (timer, w); |
535 | |
1057 | |
536 | void ev_timer_stop (struct ev_timer *w) |
1058 | void ev_timer_stop (ev_timer *w) |
|
|
1059 | CODE: |
|
|
1060 | STOP (timer, w); |
537 | |
1061 | |
538 | void ev_timer_again (struct ev_timer *w) |
1062 | void ev_timer_again (ev_timer *w) |
539 | INIT: |
1063 | INIT: |
540 | CHECK_REPEAT (w->repeat); |
1064 | CHECK_REPEAT (w->repeat); |
|
|
1065 | CODE: |
|
|
1066 | ev_timer_again (e_loop (w), w); |
|
|
1067 | UNREF (w); |
541 | |
1068 | |
|
|
1069 | NV ev_timer_remaining (ev_timer *w) |
|
|
1070 | C_ARGS: e_loop (w), w |
|
|
1071 | |
542 | void DESTROY (struct ev_timer *w) |
1072 | void DESTROY (ev_timer *w) |
543 | CODE: |
1073 | CODE: |
544 | ev_timer_stop (w); |
1074 | STOP (timer, w); |
545 | e_destroy (w); |
1075 | e_destroy (w); |
546 | |
1076 | |
547 | void set (struct ev_timer *w, NV after, NV repeat = 0.) |
1077 | void set (ev_timer *w, NV after, NV repeat = 0.) |
548 | INIT: |
1078 | INIT: |
549 | CHECK_REPEAT (repeat); |
1079 | CHECK_REPEAT (repeat); |
550 | CODE: |
1080 | CODE: |
551 | { |
|
|
552 | int active = w->active; |
|
|
553 | if (active) ev_timer_stop (w); |
|
|
554 | ev_timer_set (w, after, repeat); |
1081 | RESET (timer, w, (w, after, repeat)); |
555 | if (active) ev_timer_start (w); |
|
|
556 | } |
|
|
557 | |
1082 | |
558 | MODULE = EV PACKAGE = EV::Periodic PREFIX = ev_periodic_ |
1083 | MODULE = EV PACKAGE = EV::Periodic PREFIX = ev_periodic_ |
559 | |
1084 | |
560 | void ev_periodic_start (struct ev_periodic *w) |
1085 | void ev_periodic_start (ev_periodic *w) |
561 | INIT: |
1086 | INIT: |
562 | CHECK_REPEAT (w->interval); |
1087 | CHECK_REPEAT (w->interval); |
|
|
1088 | CODE: |
|
|
1089 | START (periodic, w); |
563 | |
1090 | |
564 | void ev_periodic_stop (struct ev_periodic *w) |
1091 | void ev_periodic_stop (ev_periodic *w) |
|
|
1092 | CODE: |
|
|
1093 | STOP (periodic, w); |
565 | |
1094 | |
|
|
1095 | void ev_periodic_again (ev_periodic *w) |
|
|
1096 | CODE: |
|
|
1097 | ev_periodic_again (e_loop (w), w); |
|
|
1098 | UNREF (w); |
|
|
1099 | |
566 | void DESTROY (struct ev_periodic *w) |
1100 | void DESTROY (ev_periodic *w) |
567 | CODE: |
1101 | CODE: |
568 | ev_periodic_stop (w); |
1102 | STOP (periodic, w); |
569 | e_destroy (w); |
1103 | e_destroy (w); |
570 | |
1104 | |
571 | void set (struct ev_periodic *w, NV at, NV interval = 0.) |
1105 | void set (ev_periodic *w, NV at, NV interval = 0., SV *reschedule_cb = &PL_sv_undef) |
572 | INIT: |
1106 | INIT: |
573 | CHECK_REPEAT (interval); |
1107 | CHECK_REPEAT (interval); |
574 | CODE: |
1108 | CODE: |
575 | { |
1109 | { |
576 | int active = w->active; |
1110 | SvREFCNT_dec (e_fh (w)); |
577 | if (active) ev_periodic_stop (w); |
1111 | e_fh (w) = SvTRUE (reschedule_cb) ? newSVsv (reschedule_cb) : 0; |
578 | ev_periodic_set (w, at, interval); |
1112 | |
579 | if (active) ev_periodic_start (w); |
1113 | RESET (periodic, w, (w, at, interval, e_fh (w) ? e_periodic_cb : 0)); |
580 | } |
1114 | } |
|
|
1115 | |
|
|
1116 | NV at (ev_periodic *w) |
|
|
1117 | CODE: |
|
|
1118 | RETVAL = ev_periodic_at (w); |
|
|
1119 | OUTPUT: |
|
|
1120 | RETVAL |
581 | |
1121 | |
582 | MODULE = EV PACKAGE = EV::Idle PREFIX = ev_idle_ |
1122 | MODULE = EV PACKAGE = EV::Idle PREFIX = ev_idle_ |
583 | |
1123 | |
584 | void ev_idle_start (struct ev_idle *w) |
1124 | void ev_idle_start (ev_idle *w) |
|
|
1125 | CODE: |
|
|
1126 | START (idle, w); |
585 | |
1127 | |
586 | void ev_idle_stop (struct ev_idle *w) |
1128 | void ev_idle_stop (ev_idle *w) |
|
|
1129 | CODE: |
|
|
1130 | STOP (idle, w); |
587 | |
1131 | |
588 | void DESTROY (struct ev_idle *w) |
1132 | void DESTROY (ev_idle *w) |
589 | CODE: |
1133 | CODE: |
590 | ev_idle_stop (w); |
1134 | STOP (idle, w); |
591 | e_destroy (w); |
1135 | e_destroy (w); |
592 | |
1136 | |
593 | MODULE = EV PACKAGE = EV::Prepare PREFIX = ev_check_ |
1137 | MODULE = EV PACKAGE = EV::Prepare PREFIX = ev_prepare_ |
594 | |
1138 | |
595 | void ev_prepare_start (struct ev_prepare *w) |
1139 | void ev_prepare_start (ev_prepare *w) |
|
|
1140 | CODE: |
|
|
1141 | START (prepare, w); |
596 | |
1142 | |
597 | void ev_prepare_stop (struct ev_prepare *w) |
1143 | void ev_prepare_stop (ev_prepare *w) |
|
|
1144 | CODE: |
|
|
1145 | STOP (prepare, w); |
598 | |
1146 | |
599 | void DESTROY (struct ev_prepare *w) |
1147 | void DESTROY (ev_prepare *w) |
600 | CODE: |
1148 | CODE: |
601 | ev_prepare_stop (w); |
1149 | STOP (prepare, w); |
602 | e_destroy (w); |
1150 | e_destroy (w); |
603 | |
1151 | |
604 | MODULE = EV PACKAGE = EV::Check PREFIX = ev_check_ |
1152 | MODULE = EV PACKAGE = EV::Check PREFIX = ev_check_ |
605 | |
1153 | |
606 | void ev_check_start (struct ev_check *w) |
1154 | void ev_check_start (ev_check *w) |
|
|
1155 | CODE: |
|
|
1156 | START (check, w); |
607 | |
1157 | |
608 | void ev_check_stop (struct ev_check *w) |
1158 | void ev_check_stop (ev_check *w) |
|
|
1159 | CODE: |
|
|
1160 | STOP (check, w); |
609 | |
1161 | |
610 | void DESTROY (struct ev_check *w) |
1162 | void DESTROY (ev_check *w) |
611 | CODE: |
1163 | CODE: |
612 | ev_check_stop (w); |
1164 | STOP (check, w); |
613 | e_destroy (w); |
1165 | e_destroy (w); |
614 | |
1166 | |
|
|
1167 | MODULE = EV PACKAGE = EV::Fork PREFIX = ev_fork_ |
|
|
1168 | |
|
|
1169 | void ev_fork_start (ev_fork *w) |
|
|
1170 | CODE: |
|
|
1171 | START (fork, w); |
|
|
1172 | |
|
|
1173 | void ev_fork_stop (ev_fork *w) |
|
|
1174 | CODE: |
|
|
1175 | STOP (fork, w); |
|
|
1176 | |
|
|
1177 | void DESTROY (ev_fork *w) |
|
|
1178 | CODE: |
|
|
1179 | STOP (fork, w); |
|
|
1180 | e_destroy (w); |
|
|
1181 | |
|
|
1182 | #if CLEANUP_ENABLED |
|
|
1183 | |
|
|
1184 | MODULE = EV PACKAGE = EV::Cleanup PREFIX = ev_cleanup_ |
|
|
1185 | |
|
|
1186 | void ev_cleanup_start (ev_cleanup *w) |
|
|
1187 | CODE: |
|
|
1188 | START (cleanup, w); |
|
|
1189 | |
|
|
1190 | void ev_cleanup_stop (ev_cleanup *w) |
|
|
1191 | CODE: |
|
|
1192 | STOP (cleanup, w); |
|
|
1193 | |
|
|
1194 | void DESTROY (ev_cleanup *w) |
|
|
1195 | CODE: |
|
|
1196 | STOP (cleanup, w); |
|
|
1197 | SvREFCNT_inc (w->loop); /* has been dec'ed on creation */ |
|
|
1198 | e_destroy (w); |
|
|
1199 | |
|
|
1200 | int keepalive (ev_watcher *w, SV *new_value = 0) |
|
|
1201 | CODE: |
|
|
1202 | RETVAL = 1; |
|
|
1203 | OUTPUT: |
|
|
1204 | RETVAL |
|
|
1205 | |
|
|
1206 | #endif |
|
|
1207 | |
615 | MODULE = EV PACKAGE = EV::Child PREFIX = ev_child_ |
1208 | MODULE = EV PACKAGE = EV::Child PREFIX = ev_child_ |
616 | |
1209 | |
|
|
1210 | #if EV_CHILD_ENABLE |
|
|
1211 | |
617 | void ev_child_start (struct ev_child *w) |
1212 | void ev_child_start (ev_child *w) |
|
|
1213 | CODE: |
|
|
1214 | START (child, w); |
618 | |
1215 | |
619 | void ev_child_stop (struct ev_child *w) |
1216 | void ev_child_stop (ev_child *w) |
|
|
1217 | CODE: |
|
|
1218 | STOP (child, w); |
620 | |
1219 | |
621 | void DESTROY (struct ev_child *w) |
1220 | void DESTROY (ev_child *w) |
622 | CODE: |
1221 | CODE: |
623 | ev_child_stop (w); |
1222 | STOP (child, w); |
624 | e_destroy (w); |
1223 | e_destroy (w); |
625 | |
1224 | |
626 | void set (struct ev_child *w, int pid) |
1225 | void set (ev_child *w, int pid, int trace) |
|
|
1226 | CODE: |
|
|
1227 | RESET (child, w, (w, pid, trace)); |
|
|
1228 | |
|
|
1229 | int pid (ev_child *w) |
|
|
1230 | ALIAS: |
|
|
1231 | rpid = 1 |
|
|
1232 | rstatus = 2 |
|
|
1233 | CODE: |
|
|
1234 | RETVAL = ix == 0 ? w->pid |
|
|
1235 | : ix == 1 ? w->rpid |
|
|
1236 | : w->rstatus; |
|
|
1237 | OUTPUT: |
|
|
1238 | RETVAL |
|
|
1239 | |
|
|
1240 | #endif |
|
|
1241 | |
|
|
1242 | MODULE = EV PACKAGE = EV::Stat PREFIX = ev_stat_ |
|
|
1243 | |
|
|
1244 | void ev_stat_start (ev_stat *w) |
|
|
1245 | CODE: |
|
|
1246 | START (stat, w); |
|
|
1247 | |
|
|
1248 | void ev_stat_stop (ev_stat *w) |
|
|
1249 | CODE: |
|
|
1250 | STOP (stat, w); |
|
|
1251 | |
|
|
1252 | void DESTROY (ev_stat *w) |
|
|
1253 | CODE: |
|
|
1254 | STOP (stat, w); |
|
|
1255 | e_destroy (w); |
|
|
1256 | |
|
|
1257 | void set (ev_stat *w, SV *path, NV interval) |
|
|
1258 | CODE: |
|
|
1259 | { |
|
|
1260 | sv_setsv (e_fh (w), path); |
|
|
1261 | RESET (stat, w, (w, SvPVbyte_nolen (e_fh (w)), interval)); |
|
|
1262 | } |
|
|
1263 | |
|
|
1264 | SV *path (ev_stat *w, SV *new_path = 0) |
|
|
1265 | CODE: |
|
|
1266 | { |
|
|
1267 | RETVAL = SvREFCNT_inc (e_fh (w)); |
|
|
1268 | |
|
|
1269 | if (items > 1) |
|
|
1270 | { |
|
|
1271 | SvREFCNT_dec (e_fh (w)); |
|
|
1272 | e_fh (w) = newSVsv (new_path); |
|
|
1273 | RESET (stat, w, (w, SvPVbyte_nolen (e_fh (w)), w->interval)); |
|
|
1274 | } |
|
|
1275 | } |
|
|
1276 | OUTPUT: |
|
|
1277 | RETVAL |
|
|
1278 | |
|
|
1279 | NV interval (ev_stat *w, NV new_interval = 0.) |
|
|
1280 | CODE: |
|
|
1281 | { |
|
|
1282 | RETVAL = w->interval; |
|
|
1283 | |
|
|
1284 | if (items > 1) |
|
|
1285 | RESET (stat, w, (w, SvPVbyte_nolen (e_fh (w)), new_interval)); |
|
|
1286 | } |
|
|
1287 | OUTPUT: |
|
|
1288 | RETVAL |
|
|
1289 | |
|
|
1290 | void prev (ev_stat *w) |
|
|
1291 | ALIAS: |
|
|
1292 | stat = 1 |
|
|
1293 | attr = 2 |
627 | CODE: |
1294 | PPCODE: |
628 | { |
1295 | { |
629 | int active = w->active; |
1296 | ev_statdata *s = ix ? &w->attr : &w->prev; |
630 | if (active) ev_child_stop (w); |
|
|
631 | ev_child_set (w, pid); |
|
|
632 | if (active) ev_child_start (w); |
|
|
633 | } |
|
|
634 | |
1297 | |
635 | int status (struct ev_child *w) |
1298 | if (ix == 1) |
|
|
1299 | ev_stat_stat (e_loop (w), w); |
|
|
1300 | else if (!s->st_nlink) |
|
|
1301 | errno = ENOENT; |
|
|
1302 | |
|
|
1303 | PL_statcache.st_dev = s->st_nlink; |
|
|
1304 | PL_statcache.st_ino = s->st_ino; |
|
|
1305 | PL_statcache.st_mode = s->st_mode; |
|
|
1306 | PL_statcache.st_nlink = s->st_nlink; |
|
|
1307 | PL_statcache.st_uid = s->st_uid; |
|
|
1308 | PL_statcache.st_gid = s->st_gid; |
|
|
1309 | PL_statcache.st_rdev = s->st_rdev; |
|
|
1310 | PL_statcache.st_size = s->st_size; |
|
|
1311 | PL_statcache.st_atime = s->st_atime; |
|
|
1312 | PL_statcache.st_mtime = s->st_mtime; |
|
|
1313 | PL_statcache.st_ctime = s->st_ctime; |
|
|
1314 | |
|
|
1315 | if (GIMME_V == G_SCALAR) |
|
|
1316 | XPUSHs (boolSV (s->st_nlink)); |
|
|
1317 | else if (GIMME_V == G_ARRAY && s->st_nlink) |
|
|
1318 | { |
|
|
1319 | EXTEND (SP, 13); |
|
|
1320 | PUSHs (sv_2mortal (newSViv (s->st_dev))); |
|
|
1321 | PUSHs (sv_2mortal (newSViv (s->st_ino))); |
|
|
1322 | PUSHs (sv_2mortal (newSVuv (s->st_mode))); |
|
|
1323 | PUSHs (sv_2mortal (newSVuv (s->st_nlink))); |
|
|
1324 | PUSHs (sv_2mortal (newSViv (s->st_uid))); |
|
|
1325 | PUSHs (sv_2mortal (newSViv (s->st_gid))); |
|
|
1326 | PUSHs (sv_2mortal (newSViv (s->st_rdev))); |
|
|
1327 | PUSHs (sv_2mortal (newSVnv ((NV)s->st_size))); |
|
|
1328 | PUSHs (sv_2mortal (newSVnv (s->st_atime))); |
|
|
1329 | PUSHs (sv_2mortal (newSVnv (s->st_mtime))); |
|
|
1330 | PUSHs (sv_2mortal (newSVnv (s->st_ctime))); |
|
|
1331 | PUSHs (sv_2mortal (newSVuv (4096))); |
|
|
1332 | PUSHs (sv_2mortal (newSVnv ((NV)((s->st_size + 4095) / 4096)))); |
|
|
1333 | } |
|
|
1334 | } |
|
|
1335 | |
|
|
1336 | MODULE = EV PACKAGE = EV::Embed PREFIX = ev_embed_ |
|
|
1337 | |
|
|
1338 | void ev_embed_start (ev_embed *w) |
636 | CODE: |
1339 | CODE: |
637 | RETVAL = w->status; |
1340 | START (embed, w); |
|
|
1341 | |
|
|
1342 | void ev_embed_stop (ev_embed *w) |
|
|
1343 | CODE: |
|
|
1344 | STOP (embed, w); |
|
|
1345 | |
|
|
1346 | void DESTROY (ev_embed *w) |
|
|
1347 | CODE: |
|
|
1348 | STOP (embed, w); |
|
|
1349 | e_destroy (w); |
|
|
1350 | |
|
|
1351 | void set (ev_embed *w, struct ev_loop *loop) |
|
|
1352 | CODE: |
|
|
1353 | { |
|
|
1354 | sv_setsv (e_fh (w), ST (1)); |
|
|
1355 | RESET (embed, w, (w, loop)); |
|
|
1356 | } |
|
|
1357 | |
|
|
1358 | SV *other (ev_embed *w) |
|
|
1359 | CODE: |
|
|
1360 | RETVAL = newSVsv (e_fh (w)); |
638 | OUTPUT: |
1361 | OUTPUT: |
639 | RETVAL |
1362 | RETVAL |
|
|
1363 | |
|
|
1364 | void ev_embed_sweep (ev_embed *w) |
|
|
1365 | C_ARGS: e_loop (w), w |
|
|
1366 | |
|
|
1367 | MODULE = EV PACKAGE = EV::Async PREFIX = ev_async_ |
|
|
1368 | |
|
|
1369 | void ev_async_start (ev_async *w) |
|
|
1370 | CODE: |
|
|
1371 | START (async, w); |
|
|
1372 | |
|
|
1373 | void ev_async_stop (ev_async *w) |
|
|
1374 | CODE: |
|
|
1375 | STOP (async, w); |
|
|
1376 | |
|
|
1377 | void DESTROY (ev_async *w) |
|
|
1378 | CODE: |
|
|
1379 | STOP (async, w); |
|
|
1380 | e_destroy (w); |
|
|
1381 | |
|
|
1382 | void ev_async_send (ev_async *w) |
|
|
1383 | C_ARGS: e_loop (w), w |
|
|
1384 | |
|
|
1385 | SV *ev_async_async_pending (ev_async *w) |
|
|
1386 | CODE: |
|
|
1387 | RETVAL = boolSV (ev_async_pending (w)); |
|
|
1388 | OUTPUT: |
|
|
1389 | RETVAL |
|
|
1390 | |
|
|
1391 | #ifndef EV_NO_LOOPS |
|
|
1392 | |
|
|
1393 | MODULE = EV PACKAGE = EV::Loop PREFIX = ev_ |
|
|
1394 | |
|
|
1395 | SV *new (SV *klass, unsigned int flags = 0) |
|
|
1396 | CODE: |
|
|
1397 | { |
|
|
1398 | struct ev_loop *loop = ev_loop_new (flags); |
|
|
1399 | |
|
|
1400 | if (!loop) |
|
|
1401 | XSRETURN_UNDEF; |
|
|
1402 | |
|
|
1403 | RETVAL = sv_bless (newRV_noinc (newSViv (PTR2IV (loop))), stash_loop); |
|
|
1404 | } |
|
|
1405 | OUTPUT: |
|
|
1406 | RETVAL |
|
|
1407 | |
|
|
1408 | void DESTROY (struct ev_loop *loop) |
|
|
1409 | CODE: |
|
|
1410 | /* 1. the default loop shouldn't be freed by destroying it's perl loop object */ |
|
|
1411 | /* 2. not doing so helps avoid many global destruction bugs in perl, too */ |
|
|
1412 | if (loop != evapi.default_loop) |
|
|
1413 | ev_loop_destroy (loop); |
|
|
1414 | |
|
|
1415 | void ev_loop_fork (struct ev_loop *loop) |
|
|
1416 | |
|
|
1417 | NV ev_now (struct ev_loop *loop) |
|
|
1418 | |
|
|
1419 | void ev_now_update (struct ev_loop *loop) |
|
|
1420 | |
|
|
1421 | void ev_suspend (struct ev_loop *loop) |
|
|
1422 | |
|
|
1423 | void ev_resume (struct ev_loop *loop) |
|
|
1424 | |
|
|
1425 | void ev_set_io_collect_interval (struct ev_loop *loop, NV interval) |
|
|
1426 | |
|
|
1427 | void ev_set_timeout_collect_interval (struct ev_loop *loop, NV interval) |
|
|
1428 | |
|
|
1429 | unsigned int ev_backend (struct ev_loop *loop) |
|
|
1430 | |
|
|
1431 | void ev_verify (struct ev_loop *loop) |
|
|
1432 | ALIAS: |
|
|
1433 | loop_verify = 1 |
|
|
1434 | |
|
|
1435 | unsigned int ev_iteration (struct ev_loop *loop) |
|
|
1436 | ALIAS: |
|
|
1437 | loop_count = 1 |
|
|
1438 | |
|
|
1439 | unsigned int ev_depth (struct ev_loop *loop) |
|
|
1440 | ALIAS: |
|
|
1441 | loop_depth = 1 |
|
|
1442 | |
|
|
1443 | int ev_run (struct ev_loop *loop, int flags = 0) |
|
|
1444 | ALIAS: |
|
|
1445 | loop = 1 |
|
|
1446 | |
|
|
1447 | void ev_break (struct ev_loop *loop, int how = 1) |
|
|
1448 | ALIAS: |
|
|
1449 | unloop = 1 |
|
|
1450 | |
|
|
1451 | void ev_feed_fd_event (struct ev_loop *loop, int fd, int revents = EV_NONE) |
|
|
1452 | |
|
|
1453 | unsigned int ev_pending_count (struct ev_loop *loop) |
|
|
1454 | |
|
|
1455 | void ev_invoke_pending (struct ev_loop *loop) |
640 | |
1456 | |
641 | #if 0 |
1457 | #if 0 |
642 | |
1458 | |
643 | MODULE = EV PACKAGE = EV::DNS PREFIX = evdns_ |
1459 | void ev_feed_signal_event (struct ev_loop *loop, SV *signal) |
644 | |
1460 | CODE: |
645 | BOOT: |
|
|
646 | { |
1461 | { |
647 | HV *stash = gv_stashpv ("EV::DNS", 1); |
1462 | Signal signum = s_signum (signal); |
|
|
1463 | CHECK_SIG (signal, signum); |
648 | |
1464 | |
649 | static const struct { |
1465 | ev_feed_signal_event (loop, signum); |
650 | const char *name; |
|
|
651 | IV iv; |
|
|
652 | } *civ, const_iv[] = { |
|
|
653 | # define const_iv(pfx, name) { # name, (IV) pfx ## name }, |
|
|
654 | const_iv (DNS_, ERR_NONE) |
|
|
655 | const_iv (DNS_, ERR_FORMAT) |
|
|
656 | const_iv (DNS_, ERR_SERVERFAILED) |
|
|
657 | const_iv (DNS_, ERR_NOTEXIST) |
|
|
658 | const_iv (DNS_, ERR_NOTIMPL) |
|
|
659 | const_iv (DNS_, ERR_REFUSED) |
|
|
660 | const_iv (DNS_, ERR_TRUNCATED) |
|
|
661 | const_iv (DNS_, ERR_UNKNOWN) |
|
|
662 | const_iv (DNS_, ERR_TIMEOUT) |
|
|
663 | const_iv (DNS_, ERR_SHUTDOWN) |
|
|
664 | const_iv (DNS_, IPv4_A) |
|
|
665 | const_iv (DNS_, PTR) |
|
|
666 | const_iv (DNS_, IPv6_AAAA) |
|
|
667 | const_iv (DNS_, QUERY_NO_SEARCH) |
|
|
668 | const_iv (DNS_, OPTION_SEARCH) |
|
|
669 | const_iv (DNS_, OPTION_NAMESERVERS) |
|
|
670 | const_iv (DNS_, OPTION_MISC) |
|
|
671 | const_iv (DNS_, OPTIONS_ALL) |
|
|
672 | const_iv (DNS_, NO_SEARCH) |
|
|
673 | }; |
|
|
674 | |
|
|
675 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
|
|
676 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
|
|
677 | } |
1466 | } |
678 | |
|
|
679 | int evdns_init () |
|
|
680 | |
|
|
681 | void evdns_shutdown (int fail_requests = 1) |
|
|
682 | |
|
|
683 | const char *evdns_err_to_string (int err) |
|
|
684 | |
|
|
685 | int evdns_nameserver_add (U32 address) |
|
|
686 | |
|
|
687 | int evdns_count_nameservers () |
|
|
688 | |
|
|
689 | int evdns_clear_nameservers_and_suspend () |
|
|
690 | |
|
|
691 | int evdns_resume () |
|
|
692 | |
|
|
693 | int evdns_nameserver_ip_add (char *ip_as_string) |
|
|
694 | |
|
|
695 | int evdns_resolve_ipv4 (const char *name, int flags, SV *cb) |
|
|
696 | C_ARGS: name, flags, dns_cb, (void *)SvREFCNT_inc (cb) |
|
|
697 | |
|
|
698 | int evdns_resolve_ipv6 (const char *name, int flags, SV *cb) |
|
|
699 | C_ARGS: name, flags, dns_cb, (void *)SvREFCNT_inc (cb) |
|
|
700 | |
|
|
701 | int evdns_resolve_reverse (SV *addr, int flags, SV *cb) |
|
|
702 | ALIAS: |
|
|
703 | evdns_resolve_reverse_ipv6 = 1 |
|
|
704 | CODE: |
|
|
705 | { |
|
|
706 | STRLEN len; |
|
|
707 | char *data = SvPVbyte (addr, len); |
|
|
708 | if (len != (ix ? 16 : 4)) |
|
|
709 | croak ("ipv4/ipv6 address to be resolved must be given as 4/16 byte octet string"); |
|
|
710 | |
|
|
711 | RETVAL = ix |
|
|
712 | ? evdns_resolve_reverse_ipv6 ((struct in6_addr *)data, flags, dns_cb, (void *)SvREFCNT_inc (cb)) |
|
|
713 | : evdns_resolve_reverse ((struct in_addr *)data, flags, dns_cb, (void *)SvREFCNT_inc (cb)); |
|
|
714 | } |
|
|
715 | OUTPUT: |
|
|
716 | RETVAL |
|
|
717 | |
|
|
718 | int evdns_set_option (char *option, char *val, int flags) |
|
|
719 | |
|
|
720 | int evdns_resolv_conf_parse (int flags, const char *filename) |
|
|
721 | |
|
|
722 | #ifdef MS_WINDOWS |
|
|
723 | |
|
|
724 | int evdns_config_windows_nameservers () |
|
|
725 | |
1467 | |
726 | #endif |
1468 | #endif |
727 | |
1469 | |
728 | void evdns_search_clear () |
1470 | ev_io *io (struct ev_loop *loop, SV *fh, int events, SV *cb) |
729 | |
1471 | ALIAS: |
730 | void evdns_search_add (char *domain) |
1472 | io_ns = 1 |
731 | |
1473 | CODE: |
732 | void evdns_search_ndots_set (int ndots) |
|
|
733 | |
|
|
734 | |
|
|
735 | MODULE = EV PACKAGE = EV::HTTP PREFIX = evhttp_ |
|
|
736 | |
|
|
737 | BOOT: |
|
|
738 | { |
1474 | { |
739 | HV *stash = gv_stashpv ("EV::HTTP", 1); |
1475 | int fd = s_fileno (fh, events & EV_WRITE); |
|
|
1476 | CHECK_FD (fh, fd); |
740 | |
1477 | |
741 | static const struct { |
1478 | RETVAL = e_new (sizeof (ev_io), cb, ST (0)); |
742 | const char *name; |
1479 | e_fh (RETVAL) = newSVsv (fh); |
743 | IV iv; |
1480 | ev_io_set (RETVAL, fd, events); |
744 | } *civ, const_iv[] = { |
1481 | if (!ix) START (io, RETVAL); |
745 | # define const_iv(pfx, name) { # name, (IV) pfx ## name }, |
|
|
746 | const_iv (HTTP_, OK) |
|
|
747 | const_iv (HTTP_, NOCONTENT) |
|
|
748 | const_iv (HTTP_, MOVEPERM) |
|
|
749 | const_iv (HTTP_, MOVETEMP) |
|
|
750 | const_iv (HTTP_, NOTMODIFIED) |
|
|
751 | const_iv (HTTP_, BADREQUEST) |
|
|
752 | const_iv (HTTP_, NOTFOUND) |
|
|
753 | const_iv (HTTP_, SERVUNAVAIL) |
|
|
754 | const_iv (EVHTTP_, REQ_OWN_CONNECTION) |
|
|
755 | const_iv (EVHTTP_, PROXY_REQUEST) |
|
|
756 | const_iv (EVHTTP_, REQ_GET) |
|
|
757 | const_iv (EVHTTP_, REQ_POST) |
|
|
758 | const_iv (EVHTTP_, REQ_HEAD) |
|
|
759 | const_iv (EVHTTP_, REQUEST) |
|
|
760 | const_iv (EVHTTP_, RESPONSE) |
|
|
761 | }; |
|
|
762 | |
|
|
763 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
|
|
764 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
|
|
765 | } |
1482 | } |
|
|
1483 | OUTPUT: |
|
|
1484 | RETVAL |
766 | |
1485 | |
767 | MODULE = EV PACKAGE = EV::HTTP::Request PREFIX = evhttp_request_ |
1486 | ev_timer *timer (struct ev_loop *loop, NV after, NV repeat, SV *cb) |
|
|
1487 | ALIAS: |
|
|
1488 | timer_ns = 1 |
|
|
1489 | INIT: |
|
|
1490 | CHECK_REPEAT (repeat); |
|
|
1491 | CODE: |
|
|
1492 | RETVAL = e_new (sizeof (ev_timer), cb, ST (0)); |
|
|
1493 | ev_timer_set (RETVAL, after, repeat); |
|
|
1494 | if (!ix) START (timer, RETVAL); |
|
|
1495 | OUTPUT: |
|
|
1496 | RETVAL |
768 | |
1497 | |
769 | #HttpRequest new (SV *klass, SV *cb) |
1498 | SV *periodic (struct ev_loop *loop, NV at, NV interval, SV *reschedule_cb, SV *cb) |
|
|
1499 | ALIAS: |
|
|
1500 | periodic_ns = 1 |
|
|
1501 | INIT: |
|
|
1502 | CHECK_REPEAT (interval); |
|
|
1503 | CODE: |
|
|
1504 | { |
|
|
1505 | ev_periodic *w; |
|
|
1506 | w = e_new (sizeof (ev_periodic), cb, ST (0)); |
|
|
1507 | e_fh (w) = SvTRUE (reschedule_cb) ? newSVsv (reschedule_cb) : 0; |
|
|
1508 | ev_periodic_set (w, at, interval, e_fh (w) ? e_periodic_cb : 0); |
|
|
1509 | RETVAL = e_bless ((ev_watcher *)w, stash_periodic); |
|
|
1510 | if (!ix) START (periodic, w); |
|
|
1511 | } |
|
|
1512 | OUTPUT: |
|
|
1513 | RETVAL |
770 | |
1514 | |
771 | #void DESTROY (struct evhttp_request *req); |
1515 | ev_signal *signal (struct ev_loop *loop, SV *signal, SV *cb) |
|
|
1516 | ALIAS: |
|
|
1517 | signal_ns = 1 |
|
|
1518 | CODE: |
|
|
1519 | { |
|
|
1520 | Signal signum = s_signum (signal); |
|
|
1521 | CHECK_SIG (signal, signum); |
|
|
1522 | |
|
|
1523 | RETVAL = e_new (sizeof (ev_signal), cb, ST (0)); |
|
|
1524 | ev_signal_set (RETVAL, signum); |
|
|
1525 | if (!ix) START_SIGNAL (RETVAL); |
|
|
1526 | } |
|
|
1527 | OUTPUT: |
|
|
1528 | RETVAL |
|
|
1529 | |
|
|
1530 | ev_idle *idle (struct ev_loop *loop, SV *cb) |
|
|
1531 | ALIAS: |
|
|
1532 | idle_ns = 1 |
|
|
1533 | CODE: |
|
|
1534 | RETVAL = e_new (sizeof (ev_idle), cb, ST (0)); |
|
|
1535 | ev_idle_set (RETVAL); |
|
|
1536 | if (!ix) START (idle, RETVAL); |
|
|
1537 | OUTPUT: |
|
|
1538 | RETVAL |
|
|
1539 | |
|
|
1540 | ev_prepare *prepare (struct ev_loop *loop, SV *cb) |
|
|
1541 | ALIAS: |
|
|
1542 | prepare_ns = 1 |
|
|
1543 | CODE: |
|
|
1544 | RETVAL = e_new (sizeof (ev_prepare), cb, ST (0)); |
|
|
1545 | ev_prepare_set (RETVAL); |
|
|
1546 | if (!ix) START (prepare, RETVAL); |
|
|
1547 | OUTPUT: |
|
|
1548 | RETVAL |
|
|
1549 | |
|
|
1550 | ev_check *check (struct ev_loop *loop, SV *cb) |
|
|
1551 | ALIAS: |
|
|
1552 | check_ns = 1 |
|
|
1553 | CODE: |
|
|
1554 | RETVAL = e_new (sizeof (ev_check), cb, ST (0)); |
|
|
1555 | ev_check_set (RETVAL); |
|
|
1556 | if (!ix) START (check, RETVAL); |
|
|
1557 | OUTPUT: |
|
|
1558 | RETVAL |
|
|
1559 | |
|
|
1560 | ev_fork *fork (struct ev_loop *loop, SV *cb) |
|
|
1561 | ALIAS: |
|
|
1562 | fork_ns = 1 |
|
|
1563 | CODE: |
|
|
1564 | RETVAL = e_new (sizeof (ev_fork), cb, ST (0)); |
|
|
1565 | ev_fork_set (RETVAL); |
|
|
1566 | if (!ix) START (fork, RETVAL); |
|
|
1567 | OUTPUT: |
|
|
1568 | RETVAL |
|
|
1569 | |
|
|
1570 | #if CLEANUP_ENABLED |
|
|
1571 | |
|
|
1572 | ev_cleanup *cleanup (struct ev_loop *loop, SV *cb) |
|
|
1573 | ALIAS: |
|
|
1574 | cleanup_ns = 1 |
|
|
1575 | CODE: |
|
|
1576 | RETVAL = e_new (sizeof (ev_cleanup), cb, ST (0)); |
|
|
1577 | SvREFCNT_dec (RETVAL->loop); /* must not keep loop object alive */ |
|
|
1578 | ev_cleanup_set (RETVAL); |
|
|
1579 | if (!ix) START (cleanup, RETVAL); |
|
|
1580 | OUTPUT: |
|
|
1581 | RETVAL |
772 | |
1582 | |
773 | #endif |
1583 | #endif |
774 | |
1584 | |
|
|
1585 | ev_child *child (struct ev_loop *loop, int pid, int trace, SV *cb) |
|
|
1586 | ALIAS: |
|
|
1587 | child_ns = 1 |
|
|
1588 | CODE: |
|
|
1589 | #if EV_CHILD_ENABLE |
|
|
1590 | RETVAL = e_new (sizeof (ev_child), cb, ST (0)); |
|
|
1591 | ev_child_set (RETVAL, pid, trace); |
|
|
1592 | if (!ix) START (child, RETVAL); |
|
|
1593 | #else |
|
|
1594 | croak ("EV::child watchers not supported on this platform"); |
|
|
1595 | #endif |
|
|
1596 | OUTPUT: |
|
|
1597 | RETVAL |
775 | |
1598 | |
|
|
1599 | ev_stat *stat (struct ev_loop *loop, SV *path, NV interval, SV *cb) |
|
|
1600 | ALIAS: |
|
|
1601 | stat_ns = 1 |
|
|
1602 | CODE: |
|
|
1603 | RETVAL = e_new (sizeof (ev_stat), cb, ST (0)); |
|
|
1604 | e_fh (RETVAL) = newSVsv (path); |
|
|
1605 | ev_stat_set (RETVAL, SvPVbyte_nolen (e_fh (RETVAL)), interval); |
|
|
1606 | if (!ix) START (stat, RETVAL); |
|
|
1607 | OUTPUT: |
|
|
1608 | RETVAL |
776 | |
1609 | |
|
|
1610 | ev_embed *embed (struct ev_loop *loop, struct ev_loop *other, SV *cb = 0) |
|
|
1611 | ALIAS: |
|
|
1612 | embed_ns = 1 |
|
|
1613 | CODE: |
|
|
1614 | { |
|
|
1615 | if (!(ev_backend (other) & ev_embeddable_backends ())) |
|
|
1616 | croak ("passed loop is not embeddable via EV::embed,"); |
777 | |
1617 | |
|
|
1618 | RETVAL = e_new (sizeof (ev_embed), cb, ST (0)); |
|
|
1619 | e_fh (RETVAL) = newSVsv (ST (1)); |
|
|
1620 | ev_embed_set (RETVAL, other); |
|
|
1621 | if (!ix) START (embed, RETVAL); |
|
|
1622 | } |
|
|
1623 | OUTPUT: |
|
|
1624 | RETVAL |
778 | |
1625 | |
|
|
1626 | ev_async *async (struct ev_loop *loop, SV *cb) |
|
|
1627 | ALIAS: |
|
|
1628 | async_ns = 1 |
|
|
1629 | CODE: |
|
|
1630 | RETVAL = e_new (sizeof (ev_async), cb, ST (0)); |
|
|
1631 | ev_async_set (RETVAL); |
|
|
1632 | if (!ix) START (async, RETVAL); |
|
|
1633 | OUTPUT: |
|
|
1634 | RETVAL |
779 | |
1635 | |
|
|
1636 | void once (struct ev_loop *loop, SV *fh, int events, SV *timeout, SV *cb) |
|
|
1637 | CODE: |
|
|
1638 | ev_once ( |
|
|
1639 | loop, |
|
|
1640 | s_fileno (fh, events & EV_WRITE), events, |
|
|
1641 | SvOK (timeout) ? SvNV (timeout) : -1., |
|
|
1642 | e_once_cb, |
|
|
1643 | newSVsv (cb) |
|
|
1644 | ); |
780 | |
1645 | |
|
|
1646 | #endif |
781 | |
1647 | |