… | |
… | |
2 | #include "perl.h" |
2 | #include "perl.h" |
3 | #include "XSUB.h" |
3 | #include "XSUB.h" |
4 | |
4 | |
5 | /*#include <netinet/in.h>*/ |
5 | /*#include <netinet/in.h>*/ |
6 | |
6 | |
7 | #define TIMEOUT_NONE HUGE_VAL |
|
|
8 | #define HAVE_EPOLL 1 |
|
|
9 | |
|
|
10 | #define EV_PROTOTYPES 1 |
7 | #define EV_PROTOTYPES 1 |
11 | #include "EV/EVAPI.h" |
8 | #include "EV/EVAPI.h" |
12 | |
9 | |
13 | #include "libev/ev.c" |
10 | #include "libev/ev.c" |
|
|
11 | #include "libev/event.h" |
|
|
12 | #include "libev/event.c" |
|
|
13 | #define DNS_USE_GETTIMEOFDAY_FOR_ID 1 |
|
|
14 | #define HAVE_STRUCT_IN6_ADDR 1 |
|
|
15 | #undef HAVE_STRTOK_R |
|
|
16 | #undef strtok_r |
|
|
17 | #define strtok_r fake_strtok_r |
|
|
18 | #include "libev/evdns.h" |
|
|
19 | #include "libev/evdns.c" |
14 | |
20 | |
15 | typedef int Signal; |
21 | typedef int Signal; |
16 | |
22 | |
17 | static struct EVAPI evapi; |
23 | static struct EVAPI evapi; |
18 | |
24 | |
19 | static HV |
25 | static HV |
20 | *stash_watcher, |
26 | *stash_watcher, |
21 | *stash_io, |
27 | *stash_io, |
22 | *stash_time, |
|
|
23 | *stash_timer, |
28 | *stash_timer, |
24 | *stash_periodic, |
29 | *stash_periodic, |
25 | *stash_signal, |
30 | *stash_signal, |
26 | *stash_idle, |
31 | *stash_idle, |
27 | *stash_prepare, |
32 | *stash_prepare, |
28 | *stash_check, |
33 | *stash_check, |
29 | *stash_child; |
34 | *stash_child; |
30 | |
35 | |
|
|
36 | #ifndef SIG_SIZE |
|
|
37 | /* kudos to Slaven Rezic for the idea */ |
|
|
38 | static char sig_size [] = { SIG_NUM }; |
|
|
39 | # define SIG_SIZE (sizeof (sig_size) + 1) |
|
|
40 | #endif |
|
|
41 | |
31 | static int |
42 | static int |
32 | sv_signum (SV *sig) |
43 | sv_signum (SV *sig) |
33 | { |
44 | { |
34 | int signum; |
45 | int signum; |
35 | |
46 | |
36 | if (SvIV (sig) > 0) |
47 | SvGETMAGIC (sig); |
37 | return SvIV (sig); |
|
|
38 | |
48 | |
39 | for (signum = 1; signum < SIG_SIZE; ++signum) |
49 | for (signum = 1; signum < SIG_SIZE; ++signum) |
40 | if (strEQ (SvPV_nolen (sig), PL_sig_name [signum])) |
50 | if (strEQ (SvPV_nolen (sig), PL_sig_name [signum])) |
41 | return signum; |
51 | return signum; |
42 | |
52 | |
|
|
53 | if (SvIV (sig) > 0) |
|
|
54 | return SvIV (sig); |
|
|
55 | |
43 | return -1; |
56 | return -1; |
44 | } |
57 | } |
45 | |
58 | |
46 | ///////////////////////////////////////////////////////////////////////////// |
59 | ///////////////////////////////////////////////////////////////////////////// |
47 | // Event |
60 | // Event |
… | |
… | |
57 | fh = SvRV (fh); |
70 | fh = SvRV (fh); |
58 | |
71 | |
59 | if (SvTYPE (fh) == SVt_PVGV) |
72 | if (SvTYPE (fh) == SVt_PVGV) |
60 | return PerlIO_fileno (IoIFP (sv_2io (fh))); |
73 | return PerlIO_fileno (IoIFP (sv_2io (fh))); |
61 | |
74 | |
62 | if (SvIOK (fh)) |
75 | if ((SvIV (fh) >= 0) && (SvIV (fh) < 0x7ffffff)) |
63 | return SvIV (fh); |
76 | return SvIV (fh); |
64 | |
77 | |
65 | return -1; |
78 | return -1; |
66 | } |
79 | } |
67 | |
80 | |
… | |
… | |
73 | SvPOK_only (self); |
86 | SvPOK_only (self); |
74 | SvCUR_set (self, size); |
87 | SvCUR_set (self, size); |
75 | |
88 | |
76 | w = (struct ev_watcher *)SvPVX (self); |
89 | w = (struct ev_watcher *)SvPVX (self); |
77 | |
90 | |
78 | evw_init (w, e_cb); |
91 | ev_watcher_init (w, e_cb); |
79 | |
92 | |
80 | w->fh = 0; |
93 | w->fh = 0; |
81 | w->cb_sv = newSVsv (cb_sv); |
94 | w->cb_sv = newSVsv (cb_sv); |
82 | w->self = self; |
95 | w->self = self; |
83 | |
96 | |
84 | return (void *)w; |
97 | return (void *)w; |
|
|
98 | } |
|
|
99 | |
|
|
100 | static void * |
|
|
101 | e_destroy (void *w_) |
|
|
102 | { |
|
|
103 | struct ev_watcher *w = w_; |
|
|
104 | |
|
|
105 | SvREFCNT_dec (w->fh ); w->fh = 0; |
|
|
106 | SvREFCNT_dec (w->cb_sv); w->cb_sv = 0; |
85 | } |
107 | } |
86 | |
108 | |
87 | static SV * |
109 | static SV * |
88 | e_bless (struct ev_watcher *w, HV *stash) |
110 | e_bless (struct ev_watcher *w, HV *stash) |
89 | { |
111 | { |
… | |
… | |
122 | PUSHMARK (SP); |
144 | PUSHMARK (SP); |
123 | EXTEND (SP, 2); |
145 | EXTEND (SP, 2); |
124 | PUSHs (sv_self); |
146 | PUSHs (sv_self); |
125 | PUSHs (sv_events); |
147 | PUSHs (sv_events); |
126 | |
148 | |
127 | if (revents & EV_CHILD) |
|
|
128 | XPUSHs (sv_status = newSViv (((struct ev_child *)w)->status)); |
|
|
129 | |
|
|
130 | PUTBACK; |
149 | PUTBACK; |
131 | call_sv (w->cb_sv, G_DISCARD | G_VOID | G_EVAL); |
150 | call_sv (w->cb_sv, G_DISCARD | G_VOID | G_EVAL); |
132 | SP = PL_stack_base + mark; PUTBACK; |
151 | SP = PL_stack_base + mark; PUTBACK; |
133 | |
152 | |
134 | SvREFCNT_dec (sv_self); |
153 | SvREFCNT_dec (sv_self); |
… | |
… | |
146 | call_sv (get_sv ("EV::DIED", 1), G_DISCARD | G_VOID | G_EVAL | G_KEEPERR); |
165 | call_sv (get_sv ("EV::DIED", 1), G_DISCARD | G_VOID | G_EVAL | G_KEEPERR); |
147 | SP = PL_stack_base + mark; PUTBACK; |
166 | SP = PL_stack_base + mark; PUTBACK; |
148 | } |
167 | } |
149 | } |
168 | } |
150 | |
169 | |
151 | #if 0 |
|
|
152 | ///////////////////////////////////////////////////////////////////////////// |
170 | ///////////////////////////////////////////////////////////////////////////// |
153 | // DNS |
171 | // DNS |
154 | |
172 | |
155 | static void |
173 | static void |
156 | dns_cb (int result, char type, int count, int ttl, void *addresses, void *arg) |
174 | dns_cb (int result, char type, int count, int ttl, void *addresses, void *arg) |
… | |
… | |
198 | call_sv (get_sv ("EV::DIED", 1), G_DISCARD | G_VOID | G_EVAL | G_KEEPERR); |
216 | call_sv (get_sv ("EV::DIED", 1), G_DISCARD | G_VOID | G_EVAL | G_KEEPERR); |
199 | } |
217 | } |
200 | |
218 | |
201 | LEAVE; |
219 | LEAVE; |
202 | } |
220 | } |
203 | #endif |
|
|
204 | |
221 | |
205 | #define CHECK_REPEAT(repeat) if (repeat < 0.) \ |
222 | #define CHECK_REPEAT(repeat) if (repeat < 0.) \ |
206 | croak (# repeat " value must be >= 0"); |
223 | croak (# repeat " value must be >= 0"); |
|
|
224 | |
|
|
225 | #define CHECK_FD(fh,fd) if ((fd) < 0) \ |
|
|
226 | croak ("illegal file descriptor or filehandle (either no attached file descriptor or illegal value): %s", SvPV_nolen (fh)); |
207 | |
227 | |
208 | ///////////////////////////////////////////////////////////////////////////// |
228 | ///////////////////////////////////////////////////////////////////////////// |
209 | // XS interface functions |
229 | // XS interface functions |
210 | |
230 | |
211 | MODULE = EV PACKAGE = EV PREFIX = ev_ |
231 | MODULE = EV PACKAGE = EV PREFIX = ev_ |
… | |
… | |
220 | static const struct { |
240 | static const struct { |
221 | const char *name; |
241 | const char *name; |
222 | IV iv; |
242 | IV iv; |
223 | } *civ, const_iv[] = { |
243 | } *civ, const_iv[] = { |
224 | # define const_iv(pfx, name) { # name, (IV) pfx ## name }, |
244 | # define const_iv(pfx, name) { # name, (IV) pfx ## name }, |
|
|
245 | const_iv (EV_, MINPRI) |
|
|
246 | const_iv (EV_, MAXPRI) |
|
|
247 | |
225 | const_iv (EV_, UNDEF) |
248 | const_iv (EV_, UNDEF) |
226 | const_iv (EV_, NONE) |
249 | const_iv (EV_, NONE) |
227 | const_iv (EV_, TIMEOUT) |
250 | const_iv (EV_, TIMEOUT) |
228 | const_iv (EV_, READ) |
251 | const_iv (EV_, READ) |
229 | const_iv (EV_, WRITE) |
252 | const_iv (EV_, WRITE) |
… | |
… | |
233 | const_iv (EV_, ERROR) |
256 | const_iv (EV_, ERROR) |
234 | |
257 | |
235 | const_iv (EV, LOOP_ONESHOT) |
258 | const_iv (EV, LOOP_ONESHOT) |
236 | const_iv (EV, LOOP_NONBLOCK) |
259 | const_iv (EV, LOOP_NONBLOCK) |
237 | |
260 | |
238 | const_iv (EV, METHOD_NONE) |
261 | const_iv (EV, METHOD_AUTO) |
239 | const_iv (EV, METHOD_SELECT) |
262 | const_iv (EV, METHOD_SELECT) |
|
|
263 | const_iv (EV, METHOD_POLL) |
240 | const_iv (EV, METHOD_EPOLL) |
264 | const_iv (EV, METHOD_EPOLL) |
|
|
265 | const_iv (EV, METHOD_KQUEUE) |
|
|
266 | const_iv (EV, METHOD_DEVPOLL) |
|
|
267 | const_iv (EV, METHOD_PORT) |
|
|
268 | const_iv (EV, METHOD_ANY) |
241 | }; |
269 | }; |
242 | |
270 | |
243 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
271 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
244 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
272 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
245 | |
273 | |
246 | stash_watcher = gv_stashpv ("EV::Watcher" , 1); |
274 | stash_watcher = gv_stashpv ("EV::Watcher" , 1); |
247 | stash_io = gv_stashpv ("EV::Io" , 1); |
275 | stash_io = gv_stashpv ("EV::Io" , 1); |
248 | stash_time = gv_stashpv ("EV::Time" , 1); |
|
|
249 | stash_timer = gv_stashpv ("EV::Timer" , 1); |
276 | stash_timer = gv_stashpv ("EV::Timer" , 1); |
250 | stash_periodic = gv_stashpv ("EV::Periodic", 1); |
277 | stash_periodic = gv_stashpv ("EV::Periodic", 1); |
251 | stash_signal = gv_stashpv ("EV::Signal" , 1); |
278 | stash_signal = gv_stashpv ("EV::Signal" , 1); |
252 | stash_idle = gv_stashpv ("EV::Idle" , 1); |
279 | stash_idle = gv_stashpv ("EV::Idle" , 1); |
253 | stash_prepare = gv_stashpv ("EV::Prepare" , 1); |
280 | stash_prepare = gv_stashpv ("EV::Prepare" , 1); |
… | |
… | |
261 | /* the poor man's shared library emulator */ |
288 | /* the poor man's shared library emulator */ |
262 | evapi.ver = EV_API_VERSION; |
289 | evapi.ver = EV_API_VERSION; |
263 | evapi.rev = EV_API_REVISION; |
290 | evapi.rev = EV_API_REVISION; |
264 | evapi.sv_fileno = sv_fileno; |
291 | evapi.sv_fileno = sv_fileno; |
265 | evapi.sv_signum = sv_signum; |
292 | evapi.sv_signum = sv_signum; |
266 | evapi.now = &ev_now; |
293 | evapi.now = ev_now; |
267 | evapi.method = &ev_method; |
294 | evapi.method = ev_method; |
268 | evapi.loop_done = &ev_loop_done; |
295 | evapi.unloop = ev_unloop; |
269 | evapi.time = ev_time; |
296 | evapi.time = ev_time; |
270 | evapi.loop = ev_loop; |
297 | evapi.loop = ev_loop; |
271 | evapi.once = ev_once; |
298 | evapi.once = ev_once; |
272 | evapi.io_start = evio_start; |
299 | evapi.io_start = ev_io_start; |
273 | evapi.io_stop = evio_stop; |
300 | evapi.io_stop = ev_io_stop; |
274 | evapi.timer_start = evtimer_start; |
301 | evapi.timer_start = ev_timer_start; |
275 | evapi.timer_stop = evtimer_stop; |
302 | evapi.timer_stop = ev_timer_stop; |
276 | evapi.timer_again = evtimer_again; |
303 | evapi.timer_again = ev_timer_again; |
277 | evapi.periodic_start = evperiodic_start; |
304 | evapi.periodic_start = ev_periodic_start; |
278 | evapi.periodic_stop = evperiodic_stop; |
305 | evapi.periodic_stop = ev_periodic_stop; |
279 | evapi.signal_start = evsignal_start; |
306 | evapi.signal_start = ev_signal_start; |
280 | evapi.signal_stop = evsignal_stop; |
307 | evapi.signal_stop = ev_signal_stop; |
281 | evapi.idle_start = evidle_start; |
308 | evapi.idle_start = ev_idle_start; |
282 | evapi.idle_stop = evidle_stop; |
309 | evapi.idle_stop = ev_idle_stop; |
283 | evapi.prepare_start = evprepare_start; |
310 | evapi.prepare_start = ev_prepare_start; |
284 | evapi.prepare_stop = evprepare_stop; |
311 | evapi.prepare_stop = ev_prepare_stop; |
285 | evapi.check_start = evcheck_start; |
312 | evapi.check_start = ev_check_start; |
286 | evapi.check_stop = evcheck_stop; |
313 | evapi.check_stop = ev_check_stop; |
287 | evapi.child_start = evchild_start; |
314 | evapi.child_start = ev_child_start; |
288 | evapi.child_stop = evchild_stop; |
315 | evapi.child_stop = ev_child_stop; |
289 | |
316 | |
290 | sv_setiv (sv, (IV)&evapi); |
317 | sv_setiv (sv, (IV)&evapi); |
291 | SvREADONLY_on (sv); |
318 | SvREADONLY_on (sv); |
292 | } |
319 | } |
|
|
320 | |
|
|
321 | pthread_atfork (0, 0, ev_default_fork); |
293 | } |
322 | } |
294 | |
323 | |
295 | NV ev_now () |
324 | NV ev_now () |
296 | CODE: |
|
|
297 | RETVAL = ev_now; |
|
|
298 | OUTPUT: |
|
|
299 | RETVAL |
|
|
300 | |
325 | |
301 | int ev_method () |
326 | int ev_method () |
302 | CODE: |
|
|
303 | RETVAL = ev_method; |
|
|
304 | OUTPUT: |
|
|
305 | RETVAL |
|
|
306 | |
327 | |
307 | NV ev_time () |
328 | NV ev_time () |
308 | |
329 | |
309 | void ev_init (int flags = 0) |
330 | int ev_default_loop (int methods = EVMETHOD_AUTO) |
310 | |
331 | |
311 | void ev_loop (int flags = 0) |
332 | void ev_loop (int flags = 0) |
312 | |
333 | |
313 | void ev_loop_done (int value = 1) |
334 | void ev_unloop (int how = 1) |
314 | CODE: |
|
|
315 | ev_loop_done = value; |
|
|
316 | |
335 | |
317 | struct ev_io *io (SV *fh, int events, SV *cb) |
336 | struct ev_io *io (SV *fh, int events, SV *cb) |
318 | ALIAS: |
337 | ALIAS: |
319 | io_ns = 1 |
338 | io_ns = 1 |
320 | CODE: |
339 | CODE: |
|
|
340 | { |
|
|
341 | int fd = sv_fileno (fh); |
|
|
342 | CHECK_FD (fh, fd); |
|
|
343 | |
321 | RETVAL = e_new (sizeof (struct ev_io), cb); |
344 | RETVAL = e_new (sizeof (struct ev_io), cb); |
322 | RETVAL->fh = newSVsv (fh); |
345 | RETVAL->fh = newSVsv (fh); |
323 | evio_set (RETVAL, sv_fileno (RETVAL->fh), events); |
346 | ev_io_set (RETVAL, fd, events); |
324 | if (!ix) evio_start (RETVAL); |
347 | if (!ix) ev_io_start (RETVAL); |
|
|
348 | } |
325 | OUTPUT: |
349 | OUTPUT: |
326 | RETVAL |
350 | RETVAL |
327 | |
351 | |
328 | struct ev_timer *timer (NV after, NV repeat, SV *cb) |
352 | struct ev_timer *timer (NV after, NV repeat, SV *cb) |
329 | ALIAS: |
353 | ALIAS: |
330 | timer_ns = 1 |
354 | timer_ns = 1 |
331 | INIT: |
355 | INIT: |
332 | CHECK_REPEAT (repeat); |
356 | CHECK_REPEAT (repeat); |
333 | CODE: |
357 | CODE: |
334 | RETVAL = e_new (sizeof (struct ev_timer), cb); |
358 | RETVAL = e_new (sizeof (struct ev_timer), cb); |
335 | evtimer_set (RETVAL, after, repeat); |
359 | ev_timer_set (RETVAL, after, repeat); |
336 | if (!ix) evtimer_start (RETVAL); |
360 | if (!ix) ev_timer_start (RETVAL); |
337 | OUTPUT: |
361 | OUTPUT: |
338 | RETVAL |
362 | RETVAL |
339 | |
363 | |
340 | struct ev_periodic *periodic (NV at, NV interval, SV *cb) |
364 | struct ev_periodic *periodic (NV at, NV interval, SV *cb) |
341 | ALIAS: |
365 | ALIAS: |
342 | periodic_ns = 1 |
366 | periodic_ns = 1 |
343 | INIT: |
367 | INIT: |
344 | CHECK_REPEAT (interval); |
368 | CHECK_REPEAT (interval); |
345 | CODE: |
369 | CODE: |
346 | RETVAL = e_new (sizeof (struct ev_periodic), cb); |
370 | RETVAL = e_new (sizeof (struct ev_periodic), cb); |
347 | evperiodic_set (RETVAL, at, interval); |
371 | ev_periodic_set (RETVAL, at, interval); |
348 | if (!ix) evperiodic_start (RETVAL); |
372 | if (!ix) ev_periodic_start (RETVAL); |
349 | OUTPUT: |
373 | OUTPUT: |
350 | RETVAL |
374 | RETVAL |
351 | |
375 | |
352 | struct ev_signal *signal (Signal signum, SV *cb) |
376 | struct ev_signal *signal (Signal signum, SV *cb) |
353 | ALIAS: |
377 | ALIAS: |
354 | signal_ns = 1 |
378 | signal_ns = 1 |
355 | CODE: |
379 | CODE: |
356 | RETVAL = e_new (sizeof (struct ev_signal), cb); |
380 | RETVAL = e_new (sizeof (struct ev_signal), cb); |
357 | evsignal_set (RETVAL, signum); |
381 | ev_signal_set (RETVAL, signum); |
358 | if (!ix) evsignal_start (RETVAL); |
382 | if (!ix) ev_signal_start (RETVAL); |
359 | OUTPUT: |
383 | OUTPUT: |
360 | RETVAL |
384 | RETVAL |
361 | |
385 | |
362 | struct ev_idle *idle (SV *cb) |
386 | struct ev_idle *idle (SV *cb) |
363 | ALIAS: |
387 | ALIAS: |
364 | idle_ns = 1 |
388 | idle_ns = 1 |
365 | CODE: |
389 | CODE: |
366 | RETVAL = e_new (sizeof (struct ev_idle), cb); |
390 | RETVAL = e_new (sizeof (struct ev_idle), cb); |
367 | evidle_set (RETVAL); |
391 | ev_idle_set (RETVAL); |
368 | if (!ix) evidle_start (RETVAL); |
392 | if (!ix) ev_idle_start (RETVAL); |
369 | OUTPUT: |
393 | OUTPUT: |
370 | RETVAL |
394 | RETVAL |
371 | |
395 | |
372 | struct ev_prepare *prepare (SV *cb) |
396 | struct ev_prepare *prepare (SV *cb) |
373 | ALIAS: |
397 | ALIAS: |
374 | prepare_ns = 1 |
398 | prepare_ns = 1 |
375 | CODE: |
399 | CODE: |
376 | RETVAL = e_new (sizeof (struct ev_prepare), cb); |
400 | RETVAL = e_new (sizeof (struct ev_prepare), cb); |
377 | evprepare_set (RETVAL); |
401 | ev_prepare_set (RETVAL); |
378 | if (!ix) evprepare_start (RETVAL); |
402 | if (!ix) ev_prepare_start (RETVAL); |
379 | OUTPUT: |
403 | OUTPUT: |
380 | RETVAL |
404 | RETVAL |
381 | |
405 | |
382 | struct ev_check *check (SV *cb) |
406 | struct ev_check *check (SV *cb) |
383 | ALIAS: |
407 | ALIAS: |
384 | check_ns = 1 |
408 | check_ns = 1 |
385 | CODE: |
409 | CODE: |
386 | RETVAL = e_new (sizeof (struct ev_check), cb); |
410 | RETVAL = e_new (sizeof (struct ev_check), cb); |
387 | evcheck_set (RETVAL); |
411 | ev_check_set (RETVAL); |
388 | if (!ix) evcheck_start (RETVAL); |
412 | if (!ix) ev_check_start (RETVAL); |
389 | OUTPUT: |
413 | OUTPUT: |
390 | RETVAL |
414 | RETVAL |
391 | |
415 | |
392 | struct ev_child *child (int pid, SV *cb) |
416 | struct ev_child *child (int pid, SV *cb) |
393 | ALIAS: |
417 | ALIAS: |
394 | check_ns = 1 |
418 | check_ns = 1 |
395 | CODE: |
419 | CODE: |
396 | RETVAL = e_new (sizeof (struct ev_check), cb); |
420 | RETVAL = e_new (sizeof (struct ev_child), cb); |
397 | evchild_set (RETVAL, pid); |
421 | ev_child_set (RETVAL, pid); |
398 | if (!ix) evchild_start (RETVAL); |
422 | if (!ix) ev_child_start (RETVAL); |
399 | OUTPUT: |
423 | OUTPUT: |
400 | RETVAL |
424 | RETVAL |
401 | |
425 | |
402 | |
426 | |
403 | PROTOTYPES: DISABLE |
427 | PROTOTYPES: DISABLE |
… | |
… | |
419 | |
443 | |
420 | void trigger (struct ev_watcher *w, int revents = EV_NONE) |
444 | void trigger (struct ev_watcher *w, int revents = EV_NONE) |
421 | CODE: |
445 | CODE: |
422 | w->cb (w, revents); |
446 | w->cb (w, revents); |
423 | |
447 | |
424 | MODULE = EV PACKAGE = EV::Io PREFIX = evio_ |
448 | int priority (struct ev_watcher *w, int new_priority = 0) |
425 | |
|
|
426 | void evio_start (struct ev_io *w) |
|
|
427 | |
|
|
428 | void evio_stop (struct ev_io *w) |
|
|
429 | |
|
|
430 | void DESTROY (struct ev_io *w) |
|
|
431 | CODE: |
449 | CODE: |
432 | evio_stop (w); |
|
|
433 | |
|
|
434 | void set (struct ev_io *w, SV *fh, int events) |
|
|
435 | CODE: |
|
|
436 | { |
450 | { |
437 | int active = w->active; |
451 | RETVAL = w->priority; |
438 | if (active) evio_stop (w); |
|
|
439 | |
|
|
440 | sv_setsv (w->fh, fh); |
|
|
441 | evio_set (w, sv_fileno (w->fh), events); |
|
|
442 | |
|
|
443 | if (active) evio_start (w); |
|
|
444 | } |
|
|
445 | |
|
|
446 | SV *fh (struct ev_io *w, SV *new_fh = 0) |
|
|
447 | CODE: |
|
|
448 | { |
|
|
449 | RETVAL = newSVsv (w->fh); |
|
|
450 | |
452 | |
451 | if (items > 1) |
453 | if (items > 1) |
452 | { |
454 | { |
453 | int active = w->active; |
455 | int active = ev_is_active (w); |
|
|
456 | |
|
|
457 | if (new_priority < EV_MINPRI || new_priority > EV_MAXPRI) |
|
|
458 | croak ("watcher priority out of range, value must be between %d and %d, inclusive", EV_MINPRI, EV_MAXPRI); |
|
|
459 | |
454 | if (active) evio_stop (w); |
460 | if (active) |
|
|
461 | { |
|
|
462 | /* grrr. */ |
|
|
463 | PUSHMARK (SP); |
|
|
464 | XPUSHs (ST (0)); |
|
|
465 | call_method ("stop", G_DISCARD | G_VOID); |
|
|
466 | } |
455 | |
467 | |
456 | sv_setsv (w->fh, new_fh); |
468 | ev_set_priority (w, new_priority); |
457 | evio_set (w, sv_fileno (w->fh), w->events); |
|
|
458 | |
469 | |
459 | if (active) evio_start (w); |
470 | if (active) |
|
|
471 | { |
|
|
472 | PUSHMARK (SP); |
|
|
473 | XPUSHs (ST (0)); |
|
|
474 | call_method ("start", G_DISCARD | G_VOID); |
|
|
475 | } |
460 | } |
476 | } |
461 | } |
477 | } |
462 | OUTPUT: |
478 | OUTPUT: |
463 | RETVAL |
479 | RETVAL |
464 | |
480 | |
465 | short events (struct ev_io *w, short new_events = EV_UNDEF) |
481 | MODULE = EV PACKAGE = EV::Io PREFIX = ev_io_ |
|
|
482 | |
|
|
483 | void ev_io_start (struct ev_io *w) |
|
|
484 | |
|
|
485 | void ev_io_stop (struct ev_io *w) |
|
|
486 | |
|
|
487 | void DESTROY (struct ev_io *w) |
466 | CODE: |
488 | CODE: |
|
|
489 | ev_io_stop (w); |
|
|
490 | e_destroy (w); |
|
|
491 | |
|
|
492 | void set (struct ev_io *w, SV *fh, int events) |
|
|
493 | CODE: |
467 | { |
494 | { |
468 | RETVAL = w->events; |
495 | int active = ev_is_active (w); |
|
|
496 | int fd = sv_fileno (fh); |
|
|
497 | CHECK_FD (fh, fd); |
|
|
498 | |
|
|
499 | if (active) ev_io_stop (w); |
|
|
500 | |
|
|
501 | sv_setsv (w->fh, fh); |
|
|
502 | ev_io_set (w, fd, events); |
|
|
503 | |
|
|
504 | if (active) ev_io_start (w); |
|
|
505 | } |
|
|
506 | |
|
|
507 | SV *fh (struct ev_io *w, SV *new_fh = 0) |
|
|
508 | CODE: |
|
|
509 | { |
|
|
510 | RETVAL = newSVsv (w->fh); |
469 | |
511 | |
470 | if (items > 1) |
512 | if (items > 1) |
471 | { |
513 | { |
472 | int active = w->active; |
514 | int active = ev_is_active (w); |
473 | if (active) evio_stop (w); |
515 | if (active) ev_io_stop (w); |
474 | |
516 | |
|
|
517 | sv_setsv (w->fh, new_fh); |
475 | evio_set (w, w->fd, new_events); |
518 | ev_io_set (w, sv_fileno (w->fh), w->events); |
476 | |
519 | |
477 | if (active) evio_start (w); |
520 | if (active) ev_io_start (w); |
478 | } |
521 | } |
479 | } |
522 | } |
480 | OUTPUT: |
523 | OUTPUT: |
481 | RETVAL |
524 | RETVAL |
482 | |
525 | |
|
|
526 | int events (struct ev_io *w, int new_events = EV_UNDEF) |
|
|
527 | CODE: |
|
|
528 | { |
|
|
529 | RETVAL = w->events; |
|
|
530 | |
|
|
531 | if (items > 1) |
|
|
532 | { |
|
|
533 | int active = ev_is_active (w); |
|
|
534 | if (active) ev_io_stop (w); |
|
|
535 | |
|
|
536 | ev_io_set (w, w->fd, new_events); |
|
|
537 | |
|
|
538 | if (active) ev_io_start (w); |
|
|
539 | } |
|
|
540 | } |
|
|
541 | OUTPUT: |
|
|
542 | RETVAL |
|
|
543 | |
483 | MODULE = EV PACKAGE = EV::Signal PREFIX = evsignal_ |
544 | MODULE = EV PACKAGE = EV::Signal PREFIX = ev_signal_ |
484 | |
545 | |
485 | void evsignal_start (struct ev_signal *w) |
546 | void ev_signal_start (struct ev_signal *w) |
486 | |
547 | |
487 | void evsignal_stop (struct ev_signal *w) |
548 | void ev_signal_stop (struct ev_signal *w) |
488 | |
549 | |
489 | void DESTROY (struct ev_signal *w) |
550 | void DESTROY (struct ev_signal *w) |
490 | CODE: |
551 | CODE: |
491 | evsignal_stop (w); |
552 | ev_signal_stop (w); |
|
|
553 | e_destroy (w); |
492 | |
554 | |
493 | void set (struct ev_signal *w, SV *signal = 0) |
555 | void set (struct ev_signal *w, SV *signal) |
494 | CODE: |
556 | CODE: |
495 | { |
557 | { |
496 | Signal signum = sv_signum (signal); /* may croak here */ |
558 | Signal signum = sv_signum (signal); /* may croak here */ |
497 | int active = w->active; |
559 | int active = ev_is_active (w); |
498 | |
560 | |
499 | if (active) evsignal_stop (w); |
561 | if (active) ev_signal_stop (w); |
|
|
562 | |
500 | evsignal_set (w, signum); |
563 | ev_signal_set (w, signum); |
|
|
564 | |
501 | if (active) evsignal_start (w); |
565 | if (active) ev_signal_start (w); |
502 | } |
566 | } |
|
|
567 | |
|
|
568 | int signal (struct ev_signal *w, SV *new_signal = 0) |
|
|
569 | CODE: |
|
|
570 | { |
|
|
571 | RETVAL = w->signum; |
|
|
572 | |
|
|
573 | if (items > 1) |
|
|
574 | { |
|
|
575 | Signal signum = sv_signum (new_signal); /* may croak here */ |
|
|
576 | int active = ev_is_active (w); |
|
|
577 | if (active) ev_signal_stop (w); |
|
|
578 | |
|
|
579 | ev_signal_set (w, signum); |
|
|
580 | |
|
|
581 | if (active) ev_signal_start (w); |
|
|
582 | } |
|
|
583 | } |
|
|
584 | OUTPUT: |
|
|
585 | RETVAL |
503 | |
586 | |
504 | MODULE = EV PACKAGE = EV::Time |
587 | MODULE = EV PACKAGE = EV::Time |
505 | |
588 | |
506 | MODULE = EV PACKAGE = EV::Timer PREFIX = evtimer_ |
589 | MODULE = EV PACKAGE = EV::Timer PREFIX = ev_timer_ |
507 | |
590 | |
508 | void evtimer_start (struct ev_timer *w) |
591 | void ev_timer_start (struct ev_timer *w) |
509 | INIT: |
592 | INIT: |
510 | CHECK_REPEAT (w->repeat); |
593 | CHECK_REPEAT (w->repeat); |
511 | |
594 | |
512 | void evtimer_stop (struct ev_timer *w) |
595 | void ev_timer_stop (struct ev_timer *w) |
513 | |
596 | |
514 | void evtimer_again (struct ev_timer *w) |
597 | void ev_timer_again (struct ev_timer *w) |
515 | INIT: |
598 | INIT: |
516 | CHECK_REPEAT (w->repeat); |
599 | CHECK_REPEAT (w->repeat); |
517 | |
600 | |
518 | void DESTROY (struct ev_timer *w) |
601 | void DESTROY (struct ev_timer *w) |
519 | CODE: |
602 | CODE: |
520 | evtimer_stop (w); |
603 | ev_timer_stop (w); |
|
|
604 | e_destroy (w); |
521 | |
605 | |
522 | void set (struct ev_timer *w, NV after, NV repeat = 0.) |
606 | void set (struct ev_timer *w, NV after, NV repeat = 0.) |
523 | INIT: |
607 | INIT: |
524 | CHECK_REPEAT (repeat); |
608 | CHECK_REPEAT (repeat); |
525 | CODE: |
609 | CODE: |
526 | { |
610 | { |
527 | int active = w->active; |
611 | int active = ev_is_active (w); |
528 | if (active) evtimer_stop (w); |
612 | if (active) ev_timer_stop (w); |
529 | evtimer_set (w, after, repeat); |
613 | ev_timer_set (w, after, repeat); |
530 | if (active) evtimer_start (w); |
614 | if (active) ev_timer_start (w); |
531 | } |
615 | } |
532 | |
616 | |
533 | MODULE = EV PACKAGE = EV::Periodic PREFIX = evperiodic_ |
617 | MODULE = EV PACKAGE = EV::Periodic PREFIX = ev_periodic_ |
534 | |
618 | |
535 | void evperiodic_start (struct ev_periodic *w) |
619 | void ev_periodic_start (struct ev_periodic *w) |
536 | INIT: |
620 | INIT: |
537 | CHECK_REPEAT (w->interval); |
621 | CHECK_REPEAT (w->interval); |
538 | |
622 | |
539 | void evperiodic_stop (struct ev_periodic *w) |
623 | void ev_periodic_stop (struct ev_periodic *w) |
540 | |
624 | |
541 | void DESTROY (struct ev_periodic *w) |
625 | void DESTROY (struct ev_periodic *w) |
542 | CODE: |
626 | CODE: |
543 | evperiodic_stop (w); |
627 | ev_periodic_stop (w); |
|
|
628 | e_destroy (w); |
544 | |
629 | |
545 | void set (struct ev_periodic *w, NV at, NV interval = 0.) |
630 | void set (struct ev_periodic *w, NV at, NV interval = 0.) |
546 | INIT: |
631 | INIT: |
547 | CHECK_REPEAT (interval); |
632 | CHECK_REPEAT (interval); |
548 | CODE: |
633 | CODE: |
549 | { |
634 | { |
550 | int active = w->active; |
635 | int active = ev_is_active (w); |
551 | if (active) evperiodic_stop (w); |
636 | if (active) ev_periodic_stop (w); |
|
|
637 | |
552 | evperiodic_set (w, at, interval); |
638 | ev_periodic_set (w, at, interval); |
|
|
639 | |
553 | if (active) evperiodic_start (w); |
640 | if (active) ev_periodic_start (w); |
554 | } |
641 | } |
555 | |
642 | |
556 | MODULE = EV PACKAGE = EV::Idle PREFIX = evidle_ |
643 | MODULE = EV PACKAGE = EV::Idle PREFIX = ev_idle_ |
557 | |
644 | |
558 | void evidle_start (struct ev_idle *w) |
645 | void ev_idle_start (struct ev_idle *w) |
559 | |
646 | |
560 | void evidle_stop (struct ev_idle *w) |
647 | void ev_idle_stop (struct ev_idle *w) |
561 | |
648 | |
562 | void DESTROY (struct ev_idle *w) |
649 | void DESTROY (struct ev_idle *w) |
563 | CODE: |
650 | CODE: |
564 | evidle_stop (w); |
651 | ev_idle_stop (w); |
|
|
652 | e_destroy (w); |
565 | |
653 | |
566 | MODULE = EV PACKAGE = EV::Prepare PREFIX = evcheck_ |
654 | MODULE = EV PACKAGE = EV::Prepare PREFIX = ev_check_ |
567 | |
655 | |
568 | void evprepare_start (struct ev_prepare *w) |
656 | void ev_prepare_start (struct ev_prepare *w) |
569 | |
657 | |
570 | void evprepare_stop (struct ev_prepare *w) |
658 | void ev_prepare_stop (struct ev_prepare *w) |
571 | |
659 | |
572 | void DESTROY (struct ev_prepare *w) |
660 | void DESTROY (struct ev_prepare *w) |
573 | CODE: |
661 | CODE: |
574 | evprepare_stop (w); |
662 | ev_prepare_stop (w); |
|
|
663 | e_destroy (w); |
575 | |
664 | |
576 | MODULE = EV PACKAGE = EV::Check PREFIX = evcheck_ |
665 | MODULE = EV PACKAGE = EV::Check PREFIX = ev_check_ |
577 | |
666 | |
578 | void evcheck_start (struct ev_check *w) |
667 | void ev_check_start (struct ev_check *w) |
579 | |
668 | |
580 | void evcheck_stop (struct ev_check *w) |
669 | void ev_check_stop (struct ev_check *w) |
581 | |
670 | |
582 | void DESTROY (struct ev_check *w) |
671 | void DESTROY (struct ev_check *w) |
583 | CODE: |
672 | CODE: |
584 | evcheck_stop (w); |
673 | ev_check_stop (w); |
|
|
674 | e_destroy (w); |
585 | |
675 | |
586 | MODULE = EV PACKAGE = EV::Child PREFIX = evchild_ |
676 | MODULE = EV PACKAGE = EV::Child PREFIX = ev_child_ |
587 | |
677 | |
588 | void evchild_start (struct ev_child *w) |
678 | void ev_child_start (struct ev_child *w) |
589 | |
679 | |
590 | void evchild_stop (struct ev_child *w) |
680 | void ev_child_stop (struct ev_child *w) |
591 | |
681 | |
592 | void DESTROY (struct ev_child *w) |
682 | void DESTROY (struct ev_child *w) |
593 | CODE: |
683 | CODE: |
594 | evchild_stop (w); |
684 | ev_child_stop (w); |
|
|
685 | e_destroy (w); |
595 | |
686 | |
596 | void set (struct ev_child *w, int pid) |
687 | void set (struct ev_child *w, int pid) |
597 | CODE: |
688 | CODE: |
598 | { |
689 | { |
599 | int active = w->active; |
690 | int active = ev_is_active (w); |
600 | if (active) evchild_stop (w); |
691 | if (active) ev_child_stop (w); |
|
|
692 | |
601 | evchild_set (w, pid); |
693 | ev_child_set (w, pid); |
|
|
694 | |
602 | if (active) evchild_start (w); |
695 | if (active) ev_child_start (w); |
603 | } |
696 | } |
604 | |
697 | |
|
|
698 | int pid (struct ev_child *w, int new_pid = 0) |
|
|
699 | CODE: |
|
|
700 | { |
|
|
701 | RETVAL = w->pid; |
|
|
702 | |
|
|
703 | if (items > 1) |
|
|
704 | { |
|
|
705 | int active = ev_is_active (w); |
|
|
706 | if (active) ev_child_stop (w); |
|
|
707 | |
|
|
708 | ev_child_set (w, new_pid); |
|
|
709 | |
|
|
710 | if (active) ev_child_start (w); |
|
|
711 | } |
|
|
712 | } |
|
|
713 | OUTPUT: |
|
|
714 | RETVAL |
|
|
715 | |
|
|
716 | |
605 | int status (struct ev_child *w) |
717 | int rstatus (struct ev_child *w) |
|
|
718 | ALIAS: |
|
|
719 | rpid = 1 |
606 | CODE: |
720 | CODE: |
607 | RETVAL = w->status; |
721 | RETVAL = ix ? w->rpid : w->rstatus; |
608 | OUTPUT: |
722 | OUTPUT: |
609 | RETVAL |
723 | RETVAL |
610 | |
|
|
611 | #if 0 |
|
|
612 | |
724 | |
613 | MODULE = EV PACKAGE = EV::DNS PREFIX = evdns_ |
725 | MODULE = EV PACKAGE = EV::DNS PREFIX = evdns_ |
614 | |
726 | |
615 | BOOT: |
727 | BOOT: |
616 | { |
728 | { |
… | |
… | |
699 | |
811 | |
700 | void evdns_search_add (char *domain) |
812 | void evdns_search_add (char *domain) |
701 | |
813 | |
702 | void evdns_search_ndots_set (int ndots) |
814 | void evdns_search_ndots_set (int ndots) |
703 | |
815 | |
|
|
816 | #if 0 |
704 | |
817 | |
705 | MODULE = EV PACKAGE = EV::HTTP PREFIX = evhttp_ |
818 | MODULE = EV PACKAGE = EV::HTTP PREFIX = evhttp_ |
706 | |
819 | |
707 | BOOT: |
820 | BOOT: |
708 | { |
821 | { |