… | |
… | |
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 EV_USE_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 | |
|
|
10 | /* fix perl api breakage */ |
|
|
11 | #undef signal |
|
|
12 | #undef sigaction |
|
|
13 | |
|
|
14 | #define EV_USE_MONOTONIC 1 |
|
|
15 | #define EV_USE_REALTIME 1 |
|
|
16 | #define EV_SELECT_IS_WINSOCKET 0 |
|
|
17 | #ifdef _WIN32 |
|
|
18 | # define EV_SELECT_USE_FD_SET 0 |
|
|
19 | # define NFDBITS PERL_NFDBITS |
|
|
20 | # define fd_mask Perl_fd_mask |
|
|
21 | #endif |
|
|
22 | /* due to bugs in OS X we have to use libev/ explicitly here */ |
13 | #include "libev/ev.c" |
23 | #include "libev/ev.c" |
|
|
24 | #include "event.c" |
|
|
25 | |
|
|
26 | #ifndef _WIN32 |
|
|
27 | #define DNS_USE_GETTIMEOFDAY_FOR_ID 1 |
|
|
28 | #if !defined (WIN32) && !defined(__CYGWIN__) |
|
|
29 | # define HAVE_STRUCT_IN6_ADDR 1 |
|
|
30 | #endif |
|
|
31 | #undef HAVE_STRTOK_R |
|
|
32 | #undef strtok_r |
|
|
33 | #define strtok_r fake_strtok_r |
|
|
34 | #include "evdns.h" |
|
|
35 | #include "evdns.c" |
|
|
36 | #endif |
|
|
37 | |
|
|
38 | #ifndef _WIN32 |
|
|
39 | # include <pthread.h> |
|
|
40 | #endif |
14 | |
41 | |
15 | typedef int Signal; |
42 | typedef int Signal; |
16 | |
43 | |
17 | static struct EVAPI evapi; |
44 | static struct EVAPI evapi; |
18 | |
45 | |
… | |
… | |
25 | *stash_idle, |
52 | *stash_idle, |
26 | *stash_prepare, |
53 | *stash_prepare, |
27 | *stash_check, |
54 | *stash_check, |
28 | *stash_child; |
55 | *stash_child; |
29 | |
56 | |
|
|
57 | #ifndef SIG_SIZE |
|
|
58 | /* kudos to Slaven Rezic for the idea */ |
|
|
59 | static char sig_size [] = { SIG_NUM }; |
|
|
60 | # define SIG_SIZE (sizeof (sig_size) + 1) |
|
|
61 | #endif |
|
|
62 | |
30 | static int |
63 | static int |
31 | sv_signum (SV *sig) |
64 | sv_signum (SV *sig) |
32 | { |
65 | { |
33 | int signum; |
66 | int signum; |
34 | |
67 | |
… | |
… | |
74 | SvPOK_only (self); |
107 | SvPOK_only (self); |
75 | SvCUR_set (self, size); |
108 | SvCUR_set (self, size); |
76 | |
109 | |
77 | w = (struct ev_watcher *)SvPVX (self); |
110 | w = (struct ev_watcher *)SvPVX (self); |
78 | |
111 | |
79 | ev_watcher_init (w, e_cb); |
112 | ev_init (w, e_cb); |
80 | |
113 | |
|
|
114 | w->data = 0; |
81 | w->fh = 0; |
115 | w->fh = 0; |
82 | w->cb_sv = newSVsv (cb_sv); |
116 | w->cb_sv = newSVsv (cb_sv); |
83 | w->self = self; |
117 | w->self = self; |
84 | |
118 | |
85 | return (void *)w; |
119 | return (void *)w; |
|
|
120 | } |
|
|
121 | |
|
|
122 | static void |
|
|
123 | e_destroy (void *w_) |
|
|
124 | { |
|
|
125 | struct ev_watcher *w = (struct ev_watcher *)w_; |
|
|
126 | |
|
|
127 | SvREFCNT_dec (w->fh ); w->fh = 0; |
|
|
128 | SvREFCNT_dec (w->cb_sv); w->cb_sv = 0; |
|
|
129 | SvREFCNT_dec (w->data ); w->data = 0; |
86 | } |
130 | } |
87 | |
131 | |
88 | static SV * |
132 | static SV * |
89 | e_bless (struct ev_watcher *w, HV *stash) |
133 | e_bless (struct ev_watcher *w, HV *stash) |
90 | { |
134 | { |
… | |
… | |
108 | dSP; |
152 | dSP; |
109 | I32 mark = SP - PL_stack_base; |
153 | I32 mark = SP - PL_stack_base; |
110 | SV *sv_self, *sv_events, *sv_status = 0; |
154 | SV *sv_self, *sv_events, *sv_status = 0; |
111 | static SV *sv_events_cache; |
155 | static SV *sv_events_cache; |
112 | |
156 | |
113 | fprintf (stderr, "e_cb %p,%x\n", w, revents);//D |
|
|
114 | |
|
|
115 | sv_self = newRV_inc (w->self); /* w->self MUST be blessed by now */ |
157 | sv_self = newRV_inc (w->self); /* w->self MUST be blessed by now */ |
116 | |
158 | |
117 | if (sv_events_cache) |
159 | if (sv_events_cache) |
118 | { |
160 | { |
119 | sv_events = sv_events_cache; sv_events_cache = 0; |
161 | sv_events = sv_events_cache; sv_events_cache = 0; |
… | |
… | |
125 | PUSHMARK (SP); |
167 | PUSHMARK (SP); |
126 | EXTEND (SP, 2); |
168 | EXTEND (SP, 2); |
127 | PUSHs (sv_self); |
169 | PUSHs (sv_self); |
128 | PUSHs (sv_events); |
170 | PUSHs (sv_events); |
129 | |
171 | |
130 | if (revents & EV_CHILD) |
|
|
131 | XPUSHs (sv_status = newSViv (((struct ev_child *)w)->status)); |
|
|
132 | |
|
|
133 | PUTBACK; |
172 | PUTBACK; |
134 | call_sv (w->cb_sv, G_DISCARD | G_VOID | G_EVAL); |
173 | call_sv (w->cb_sv, G_DISCARD | G_VOID | G_EVAL); |
135 | SP = PL_stack_base + mark; PUTBACK; |
|
|
136 | |
174 | |
137 | SvREFCNT_dec (sv_self); |
175 | SvREFCNT_dec (sv_self); |
138 | SvREFCNT_dec (sv_status); |
176 | SvREFCNT_dec (sv_status); |
139 | |
177 | |
140 | if (sv_events_cache) |
178 | if (sv_events_cache) |
… | |
… | |
145 | if (SvTRUE (ERRSV)) |
183 | if (SvTRUE (ERRSV)) |
146 | { |
184 | { |
147 | PUSHMARK (SP); |
185 | PUSHMARK (SP); |
148 | PUTBACK; |
186 | PUTBACK; |
149 | call_sv (get_sv ("EV::DIED", 1), G_DISCARD | G_VOID | G_EVAL | G_KEEPERR); |
187 | call_sv (get_sv ("EV::DIED", 1), G_DISCARD | G_VOID | G_EVAL | G_KEEPERR); |
150 | SP = PL_stack_base + mark; PUTBACK; |
|
|
151 | } |
188 | } |
152 | } |
|
|
153 | |
189 | |
154 | #if 0 |
190 | SP = PL_stack_base + mark; |
|
|
191 | PUTBACK; |
|
|
192 | } |
|
|
193 | |
|
|
194 | static ev_tstamp |
|
|
195 | e_periodic_cb (struct ev_periodic *w, ev_tstamp now) |
|
|
196 | { |
|
|
197 | ev_tstamp retval; |
|
|
198 | int count; |
|
|
199 | dSP; |
|
|
200 | |
|
|
201 | ENTER; |
|
|
202 | SAVETMPS; |
|
|
203 | |
|
|
204 | PUSHMARK (SP); |
|
|
205 | EXTEND (SP, 2); |
|
|
206 | PUSHs (newRV_inc (w->self)); /* w->self MUST be blessed by now */ |
|
|
207 | PUSHs (newSVnv (now)); |
|
|
208 | |
|
|
209 | PUTBACK; |
|
|
210 | count = call_sv (w->fh, G_SCALAR | G_EVAL); |
|
|
211 | SPAGAIN; |
|
|
212 | |
|
|
213 | if (SvTRUE (ERRSV)) |
|
|
214 | { |
|
|
215 | PUSHMARK (SP); |
|
|
216 | PUTBACK; |
|
|
217 | call_sv (get_sv ("EV::DIED", 1), G_DISCARD | G_VOID | G_EVAL | G_KEEPERR); |
|
|
218 | SPAGAIN; |
|
|
219 | } |
|
|
220 | |
|
|
221 | if (count > 0) |
|
|
222 | { |
|
|
223 | retval = SvNV (TOPs); |
|
|
224 | |
|
|
225 | if (retval < now) |
|
|
226 | retval = now; |
|
|
227 | } |
|
|
228 | else |
|
|
229 | retval = now; |
|
|
230 | |
|
|
231 | FREETMPS; |
|
|
232 | LEAVE; |
|
|
233 | |
|
|
234 | return retval; |
|
|
235 | } |
|
|
236 | |
155 | ///////////////////////////////////////////////////////////////////////////// |
237 | ///////////////////////////////////////////////////////////////////////////// |
156 | // DNS |
238 | // DNS |
157 | |
239 | |
|
|
240 | #ifndef _WIN32 |
158 | static void |
241 | static void |
159 | dns_cb (int result, char type, int count, int ttl, void *addresses, void *arg) |
242 | dns_cb (int result, char type, int count, int ttl, void *addresses, void *arg) |
160 | { |
243 | { |
161 | dSP; |
244 | dSP; |
162 | SV *cb = (SV *)arg; |
245 | SV *cb = (SV *)arg; |
… | |
… | |
218 | |
301 | |
219 | PROTOTYPES: ENABLE |
302 | PROTOTYPES: ENABLE |
220 | |
303 | |
221 | BOOT: |
304 | BOOT: |
222 | { |
305 | { |
223 | int i; |
|
|
224 | HV *stash = gv_stashpv ("EV", 1); |
306 | HV *stash = gv_stashpv ("EV", 1); |
225 | |
307 | |
226 | static const struct { |
308 | static const struct { |
227 | const char *name; |
309 | const char *name; |
228 | IV iv; |
310 | IV iv; |
229 | } *civ, const_iv[] = { |
311 | } *civ, const_iv[] = { |
230 | # define const_iv(pfx, name) { # name, (IV) pfx ## name }, |
312 | # define const_iv(pfx, name) { # name, (IV) pfx ## name }, |
|
|
313 | const_iv (EV_, MINPRI) |
|
|
314 | const_iv (EV_, MAXPRI) |
|
|
315 | |
231 | const_iv (EV_, UNDEF) |
316 | const_iv (EV_, UNDEF) |
232 | const_iv (EV_, NONE) |
317 | const_iv (EV_, NONE) |
233 | const_iv (EV_, TIMEOUT) |
318 | const_iv (EV_, TIMEOUT) |
234 | const_iv (EV_, READ) |
319 | const_iv (EV_, READ) |
235 | const_iv (EV_, WRITE) |
320 | const_iv (EV_, WRITE) |
… | |
… | |
238 | const_iv (EV_, CHECK) |
323 | const_iv (EV_, CHECK) |
239 | const_iv (EV_, ERROR) |
324 | const_iv (EV_, ERROR) |
240 | |
325 | |
241 | const_iv (EV, LOOP_ONESHOT) |
326 | const_iv (EV, LOOP_ONESHOT) |
242 | const_iv (EV, LOOP_NONBLOCK) |
327 | const_iv (EV, LOOP_NONBLOCK) |
243 | |
|
|
244 | const_iv (EV, METHOD_NONE) |
328 | const_iv (EV, UNLOOP_ONE) |
|
|
329 | const_iv (EV, UNLOOP_ALL) |
|
|
330 | |
245 | const_iv (EV, METHOD_SELECT) |
331 | const_iv (EV, METHOD_SELECT) |
|
|
332 | const_iv (EV, METHOD_POLL) |
246 | const_iv (EV, METHOD_EPOLL) |
333 | const_iv (EV, METHOD_EPOLL) |
|
|
334 | const_iv (EV, METHOD_KQUEUE) |
|
|
335 | const_iv (EV, METHOD_DEVPOLL) |
|
|
336 | const_iv (EV, METHOD_PORT) |
|
|
337 | const_iv (EV, FLAG_AUTO) |
|
|
338 | const_iv (EV, FLAG_NOENV) |
247 | }; |
339 | }; |
248 | |
340 | |
249 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
341 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
250 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
342 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
251 | |
343 | |
… | |
… | |
266 | /* the poor man's shared library emulator */ |
358 | /* the poor man's shared library emulator */ |
267 | evapi.ver = EV_API_VERSION; |
359 | evapi.ver = EV_API_VERSION; |
268 | evapi.rev = EV_API_REVISION; |
360 | evapi.rev = EV_API_REVISION; |
269 | evapi.sv_fileno = sv_fileno; |
361 | evapi.sv_fileno = sv_fileno; |
270 | evapi.sv_signum = sv_signum; |
362 | evapi.sv_signum = sv_signum; |
271 | evapi.now = &ev_now; |
363 | evapi.now = ev_now; |
272 | evapi.method = &ev_method; |
364 | evapi.method = ev_method; |
273 | evapi.loop_done = &ev_loop_done; |
365 | evapi.unloop = ev_unloop; |
274 | evapi.time = ev_time; |
366 | evapi.time = ev_time; |
275 | evapi.loop = ev_loop; |
367 | evapi.loop = ev_loop; |
276 | evapi.once = ev_once; |
368 | evapi.once = ev_once; |
277 | evapi.io_start = ev_io_start; |
369 | evapi.io_start = ev_io_start; |
278 | evapi.io_stop = ev_io_stop; |
370 | evapi.io_stop = ev_io_stop; |
… | |
… | |
293 | evapi.child_stop = ev_child_stop; |
385 | evapi.child_stop = ev_child_stop; |
294 | |
386 | |
295 | sv_setiv (sv, (IV)&evapi); |
387 | sv_setiv (sv, (IV)&evapi); |
296 | SvREADONLY_on (sv); |
388 | SvREADONLY_on (sv); |
297 | } |
389 | } |
|
|
390 | #ifndef _WIN32 |
|
|
391 | pthread_atfork (0, 0, ev_default_fork); |
|
|
392 | #endif |
298 | } |
393 | } |
299 | |
394 | |
300 | NV ev_now () |
395 | NV ev_now () |
301 | CODE: |
|
|
302 | RETVAL = ev_now; |
|
|
303 | OUTPUT: |
|
|
304 | RETVAL |
|
|
305 | |
396 | |
306 | int ev_method () |
397 | int ev_method () |
307 | CODE: |
|
|
308 | RETVAL = ev_method; |
|
|
309 | OUTPUT: |
|
|
310 | RETVAL |
|
|
311 | |
398 | |
312 | NV ev_time () |
399 | NV ev_time () |
313 | |
400 | |
314 | void ev_init (int flags = 0) |
401 | int ev_default_loop (int methods = EVFLAG_AUTO) |
315 | |
402 | |
316 | void ev_loop (int flags = 0) |
403 | void ev_loop (int flags = 0) |
317 | |
404 | |
318 | void ev_loop_done (int value = 1) |
405 | void ev_unloop (int how = 1) |
319 | CODE: |
|
|
320 | ev_loop_done = value; |
|
|
321 | |
406 | |
322 | struct ev_io *io (SV *fh, int events, SV *cb) |
407 | struct ev_io *io (SV *fh, int events, SV *cb) |
323 | ALIAS: |
408 | ALIAS: |
324 | io_ns = 1 |
409 | io_ns = 1 |
325 | CODE: |
410 | CODE: |
… | |
… | |
345 | ev_timer_set (RETVAL, after, repeat); |
430 | ev_timer_set (RETVAL, after, repeat); |
346 | if (!ix) ev_timer_start (RETVAL); |
431 | if (!ix) ev_timer_start (RETVAL); |
347 | OUTPUT: |
432 | OUTPUT: |
348 | RETVAL |
433 | RETVAL |
349 | |
434 | |
350 | struct ev_periodic *periodic (NV at, NV interval, SV *cb) |
435 | SV *periodic (NV at, NV interval, SV *reschedule_cb, SV *cb) |
351 | ALIAS: |
436 | ALIAS: |
352 | periodic_ns = 1 |
437 | periodic_ns = 1 |
353 | INIT: |
438 | INIT: |
354 | CHECK_REPEAT (interval); |
439 | CHECK_REPEAT (interval); |
355 | CODE: |
440 | CODE: |
|
|
441 | { |
|
|
442 | struct ev_periodic *w; |
356 | RETVAL = e_new (sizeof (struct ev_periodic), cb); |
443 | w = e_new (sizeof (struct ev_periodic), cb); |
357 | ev_periodic_set (RETVAL, at, interval); |
444 | w->fh = SvTRUE (reschedule_cb) ? newSVsv (reschedule_cb) : 0; |
|
|
445 | ev_periodic_set (w, at, interval, w->fh ? e_periodic_cb : 0); |
|
|
446 | RETVAL = e_bless ((struct ev_watcher *)w, stash_periodic); |
358 | if (!ix) ev_periodic_start (RETVAL); |
447 | if (!ix) ev_periodic_start (w); |
|
|
448 | } |
359 | OUTPUT: |
449 | OUTPUT: |
360 | RETVAL |
450 | RETVAL |
361 | |
451 | |
362 | struct ev_signal *signal (Signal signum, SV *cb) |
452 | struct ev_signal *signal (Signal signum, SV *cb) |
363 | ALIAS: |
453 | ALIAS: |
… | |
… | |
399 | OUTPUT: |
489 | OUTPUT: |
400 | RETVAL |
490 | RETVAL |
401 | |
491 | |
402 | struct ev_child *child (int pid, SV *cb) |
492 | struct ev_child *child (int pid, SV *cb) |
403 | ALIAS: |
493 | ALIAS: |
404 | check_ns = 1 |
494 | child_ns = 1 |
405 | CODE: |
495 | CODE: |
406 | RETVAL = e_new (sizeof (struct ev_check), cb); |
496 | RETVAL = e_new (sizeof (struct ev_child), cb); |
407 | ev_child_set (RETVAL, pid); |
497 | ev_child_set (RETVAL, pid); |
408 | if (!ix) ev_child_start (RETVAL); |
498 | if (!ix) ev_child_start (RETVAL); |
409 | OUTPUT: |
499 | OUTPUT: |
410 | RETVAL |
500 | RETVAL |
411 | |
501 | |
… | |
… | |
425 | sv_setsv (w->cb_sv, new_cb); |
515 | sv_setsv (w->cb_sv, new_cb); |
426 | } |
516 | } |
427 | OUTPUT: |
517 | OUTPUT: |
428 | RETVAL |
518 | RETVAL |
429 | |
519 | |
|
|
520 | SV *data (struct ev_watcher *w, SV *new_data = 0) |
|
|
521 | CODE: |
|
|
522 | { |
|
|
523 | RETVAL = w->data ? newSVsv (w->data) : &PL_sv_undef; |
|
|
524 | } |
|
|
525 | OUTPUT: |
|
|
526 | RETVAL |
|
|
527 | |
430 | void trigger (struct ev_watcher *w, int revents = EV_NONE) |
528 | void trigger (struct ev_watcher *w, int revents = EV_NONE) |
431 | CODE: |
529 | CODE: |
432 | w->cb (w, revents); |
530 | w->cb (w, revents); |
433 | |
531 | |
|
|
532 | int priority (struct ev_watcher *w, int new_priority = 0) |
|
|
533 | CODE: |
|
|
534 | { |
|
|
535 | RETVAL = w->priority; |
|
|
536 | |
|
|
537 | if (items > 1) |
|
|
538 | { |
|
|
539 | int active = ev_is_active (w); |
|
|
540 | |
|
|
541 | if (new_priority < EV_MINPRI || new_priority > EV_MAXPRI) |
|
|
542 | croak ("watcher priority out of range, value must be between %d and %d, inclusive", EV_MINPRI, EV_MAXPRI); |
|
|
543 | |
|
|
544 | if (active) |
|
|
545 | { |
|
|
546 | /* grrr. */ |
|
|
547 | PUSHMARK (SP); |
|
|
548 | XPUSHs (ST (0)); |
|
|
549 | call_method ("stop", G_DISCARD | G_VOID); |
|
|
550 | } |
|
|
551 | |
|
|
552 | ev_set_priority (w, new_priority); |
|
|
553 | |
|
|
554 | if (active) |
|
|
555 | { |
|
|
556 | PUSHMARK (SP); |
|
|
557 | XPUSHs (ST (0)); |
|
|
558 | call_method ("start", G_DISCARD | G_VOID); |
|
|
559 | } |
|
|
560 | } |
|
|
561 | } |
|
|
562 | OUTPUT: |
|
|
563 | RETVAL |
|
|
564 | |
434 | MODULE = EV PACKAGE = EV::Io PREFIX = ev_io_ |
565 | MODULE = EV PACKAGE = EV::Io PREFIX = ev_io_ |
435 | |
566 | |
436 | void ev_io_start (struct ev_io *w) |
567 | void ev_io_start (struct ev_io *w) |
437 | |
568 | |
438 | void ev_io_stop (struct ev_io *w) |
569 | void ev_io_stop (struct ev_io *w) |
439 | |
570 | |
440 | void DESTROY (struct ev_io *w) |
571 | void DESTROY (struct ev_io *w) |
441 | CODE: |
572 | CODE: |
442 | ev_io_stop (w); |
573 | ev_io_stop (w); |
|
|
574 | e_destroy (w); |
443 | |
575 | |
444 | void set (struct ev_io *w, SV *fh, int events) |
576 | void set (struct ev_io *w, SV *fh, int events) |
445 | CODE: |
577 | CODE: |
446 | { |
578 | { |
447 | int active = w->active; |
579 | int active = ev_is_active (w); |
448 | int fd = sv_fileno (fh); |
580 | int fd = sv_fileno (fh); |
449 | CHECK_FD (fh, fd); |
581 | CHECK_FD (fh, fd); |
450 | |
582 | |
451 | if (active) ev_io_stop (w); |
583 | if (active) ev_io_stop (w); |
452 | |
584 | |
… | |
… | |
461 | { |
593 | { |
462 | RETVAL = newSVsv (w->fh); |
594 | RETVAL = newSVsv (w->fh); |
463 | |
595 | |
464 | if (items > 1) |
596 | if (items > 1) |
465 | { |
597 | { |
466 | int active = w->active; |
598 | int active = ev_is_active (w); |
467 | if (active) ev_io_stop (w); |
599 | if (active) ev_io_stop (w); |
468 | |
600 | |
469 | sv_setsv (w->fh, new_fh); |
601 | sv_setsv (w->fh, new_fh); |
470 | ev_io_set (w, sv_fileno (w->fh), w->events); |
602 | ev_io_set (w, sv_fileno (w->fh), w->events); |
471 | |
603 | |
… | |
… | |
473 | } |
605 | } |
474 | } |
606 | } |
475 | OUTPUT: |
607 | OUTPUT: |
476 | RETVAL |
608 | RETVAL |
477 | |
609 | |
478 | short events (struct ev_io *w, short new_events = EV_UNDEF) |
610 | int events (struct ev_io *w, int new_events = EV_UNDEF) |
479 | CODE: |
611 | CODE: |
480 | { |
612 | { |
481 | RETVAL = w->events; |
613 | RETVAL = w->events; |
482 | |
614 | |
483 | if (items > 1) |
615 | if (items > 1) |
484 | { |
616 | { |
485 | int active = w->active; |
617 | int active = ev_is_active (w); |
486 | if (active) ev_io_stop (w); |
618 | if (active) ev_io_stop (w); |
487 | |
619 | |
488 | ev_io_set (w, w->fd, new_events); |
620 | ev_io_set (w, w->fd, new_events); |
489 | |
621 | |
490 | if (active) ev_io_start (w); |
622 | if (active) ev_io_start (w); |
… | |
… | |
500 | void ev_signal_stop (struct ev_signal *w) |
632 | void ev_signal_stop (struct ev_signal *w) |
501 | |
633 | |
502 | void DESTROY (struct ev_signal *w) |
634 | void DESTROY (struct ev_signal *w) |
503 | CODE: |
635 | CODE: |
504 | ev_signal_stop (w); |
636 | ev_signal_stop (w); |
|
|
637 | e_destroy (w); |
505 | |
638 | |
506 | void set (struct ev_signal *w, SV *signal = 0) |
639 | void set (struct ev_signal *w, SV *signal) |
507 | CODE: |
640 | CODE: |
508 | { |
641 | { |
509 | Signal signum = sv_signum (signal); /* may croak here */ |
642 | Signal signum = sv_signum (signal); /* may croak here */ |
510 | int active = w->active; |
643 | int active = ev_is_active (w); |
511 | |
644 | |
512 | if (active) ev_signal_stop (w); |
645 | if (active) ev_signal_stop (w); |
|
|
646 | |
513 | ev_signal_set (w, signum); |
647 | ev_signal_set (w, signum); |
|
|
648 | |
514 | if (active) ev_signal_start (w); |
649 | if (active) ev_signal_start (w); |
515 | } |
650 | } |
516 | |
651 | |
517 | MODULE = EV PACKAGE = EV::Time |
652 | int signal (struct ev_signal *w, SV *new_signal = 0) |
|
|
653 | CODE: |
|
|
654 | { |
|
|
655 | RETVAL = w->signum; |
|
|
656 | |
|
|
657 | if (items > 1) |
|
|
658 | { |
|
|
659 | Signal signum = sv_signum (new_signal); /* may croak here */ |
|
|
660 | int active = ev_is_active (w); |
|
|
661 | if (active) ev_signal_stop (w); |
|
|
662 | |
|
|
663 | ev_signal_set (w, signum); |
|
|
664 | |
|
|
665 | if (active) ev_signal_start (w); |
|
|
666 | } |
|
|
667 | } |
|
|
668 | OUTPUT: |
|
|
669 | RETVAL |
518 | |
670 | |
519 | MODULE = EV PACKAGE = EV::Timer PREFIX = ev_timer_ |
671 | MODULE = EV PACKAGE = EV::Timer PREFIX = ev_timer_ |
520 | |
672 | |
521 | void ev_timer_start (struct ev_timer *w) |
673 | void ev_timer_start (struct ev_timer *w) |
522 | INIT: |
674 | INIT: |
… | |
… | |
529 | CHECK_REPEAT (w->repeat); |
681 | CHECK_REPEAT (w->repeat); |
530 | |
682 | |
531 | void DESTROY (struct ev_timer *w) |
683 | void DESTROY (struct ev_timer *w) |
532 | CODE: |
684 | CODE: |
533 | ev_timer_stop (w); |
685 | ev_timer_stop (w); |
|
|
686 | e_destroy (w); |
534 | |
687 | |
535 | void set (struct ev_timer *w, NV after, NV repeat = 0.) |
688 | void set (struct ev_timer *w, NV after, NV repeat = 0.) |
536 | INIT: |
689 | INIT: |
537 | CHECK_REPEAT (repeat); |
690 | CHECK_REPEAT (repeat); |
538 | CODE: |
691 | CODE: |
539 | { |
692 | { |
540 | int active = w->active; |
693 | int active = ev_is_active (w); |
541 | if (active) ev_timer_stop (w); |
694 | if (active) ev_timer_stop (w); |
542 | ev_timer_set (w, after, repeat); |
695 | ev_timer_set (w, after, repeat); |
543 | if (active) ev_timer_start (w); |
696 | if (active) ev_timer_start (w); |
544 | } |
697 | } |
545 | |
698 | |
… | |
… | |
549 | INIT: |
702 | INIT: |
550 | CHECK_REPEAT (w->interval); |
703 | CHECK_REPEAT (w->interval); |
551 | |
704 | |
552 | void ev_periodic_stop (struct ev_periodic *w) |
705 | void ev_periodic_stop (struct ev_periodic *w) |
553 | |
706 | |
|
|
707 | void ev_periodic_again (struct ev_periodic *w) |
|
|
708 | |
554 | void DESTROY (struct ev_periodic *w) |
709 | void DESTROY (struct ev_periodic *w) |
555 | CODE: |
710 | CODE: |
556 | ev_periodic_stop (w); |
711 | ev_periodic_stop (w); |
|
|
712 | e_destroy (w); |
557 | |
713 | |
558 | void set (struct ev_periodic *w, NV at, NV interval = 0.) |
714 | void set (struct ev_periodic *w, NV at, NV interval = 0., SV *reschedule_cb = &PL_sv_undef) |
559 | INIT: |
715 | INIT: |
560 | CHECK_REPEAT (interval); |
716 | CHECK_REPEAT (interval); |
561 | CODE: |
717 | CODE: |
562 | { |
718 | { |
563 | int active = w->active; |
719 | int active = ev_is_active (w); |
564 | if (active) ev_periodic_stop (w); |
720 | if (active) ev_periodic_stop (w); |
|
|
721 | |
|
|
722 | SvREFCNT_dec (w->fh); |
|
|
723 | w->fh = SvTRUE (reschedule_cb) ? newSVsv (reschedule_cb) : 0; |
565 | ev_periodic_set (w, at, interval); |
724 | ev_periodic_set (w, at, interval, w->fh ? e_periodic_cb : 0); |
|
|
725 | |
566 | if (active) ev_periodic_start (w); |
726 | if (active) ev_periodic_start (w); |
567 | } |
727 | } |
568 | |
728 | |
569 | MODULE = EV PACKAGE = EV::Idle PREFIX = ev_idle_ |
729 | MODULE = EV PACKAGE = EV::Idle PREFIX = ev_idle_ |
570 | |
730 | |
… | |
… | |
573 | void ev_idle_stop (struct ev_idle *w) |
733 | void ev_idle_stop (struct ev_idle *w) |
574 | |
734 | |
575 | void DESTROY (struct ev_idle *w) |
735 | void DESTROY (struct ev_idle *w) |
576 | CODE: |
736 | CODE: |
577 | ev_idle_stop (w); |
737 | ev_idle_stop (w); |
|
|
738 | e_destroy (w); |
578 | |
739 | |
579 | MODULE = EV PACKAGE = EV::Prepare PREFIX = ev_check_ |
740 | MODULE = EV PACKAGE = EV::Prepare PREFIX = ev_check_ |
580 | |
741 | |
581 | void ev_prepare_start (struct ev_prepare *w) |
742 | void ev_prepare_start (struct ev_prepare *w) |
582 | |
743 | |
583 | void ev_prepare_stop (struct ev_prepare *w) |
744 | void ev_prepare_stop (struct ev_prepare *w) |
584 | |
745 | |
585 | void DESTROY (struct ev_prepare *w) |
746 | void DESTROY (struct ev_prepare *w) |
586 | CODE: |
747 | CODE: |
587 | ev_prepare_stop (w); |
748 | ev_prepare_stop (w); |
|
|
749 | e_destroy (w); |
588 | |
750 | |
589 | MODULE = EV PACKAGE = EV::Check PREFIX = ev_check_ |
751 | MODULE = EV PACKAGE = EV::Check PREFIX = ev_check_ |
590 | |
752 | |
591 | void ev_check_start (struct ev_check *w) |
753 | void ev_check_start (struct ev_check *w) |
592 | |
754 | |
593 | void ev_check_stop (struct ev_check *w) |
755 | void ev_check_stop (struct ev_check *w) |
594 | |
756 | |
595 | void DESTROY (struct ev_check *w) |
757 | void DESTROY (struct ev_check *w) |
596 | CODE: |
758 | CODE: |
597 | ev_check_stop (w); |
759 | ev_check_stop (w); |
|
|
760 | e_destroy (w); |
598 | |
761 | |
599 | MODULE = EV PACKAGE = EV::Child PREFIX = ev_child_ |
762 | MODULE = EV PACKAGE = EV::Child PREFIX = ev_child_ |
600 | |
763 | |
601 | void ev_child_start (struct ev_child *w) |
764 | void ev_child_start (struct ev_child *w) |
602 | |
765 | |
603 | void ev_child_stop (struct ev_child *w) |
766 | void ev_child_stop (struct ev_child *w) |
604 | |
767 | |
605 | void DESTROY (struct ev_child *w) |
768 | void DESTROY (struct ev_child *w) |
606 | CODE: |
769 | CODE: |
607 | ev_child_stop (w); |
770 | ev_child_stop (w); |
|
|
771 | e_destroy (w); |
608 | |
772 | |
609 | void set (struct ev_child *w, int pid) |
773 | void set (struct ev_child *w, int pid) |
610 | CODE: |
774 | CODE: |
611 | { |
775 | { |
612 | int active = w->active; |
776 | int active = ev_is_active (w); |
613 | if (active) ev_child_stop (w); |
777 | if (active) ev_child_stop (w); |
|
|
778 | |
614 | ev_child_set (w, pid); |
779 | ev_child_set (w, pid); |
|
|
780 | |
615 | if (active) ev_child_start (w); |
781 | if (active) ev_child_start (w); |
616 | } |
782 | } |
617 | |
783 | |
|
|
784 | int pid (struct ev_child *w, int new_pid = 0) |
|
|
785 | CODE: |
|
|
786 | { |
|
|
787 | RETVAL = w->pid; |
|
|
788 | |
|
|
789 | if (items > 1) |
|
|
790 | { |
|
|
791 | int active = ev_is_active (w); |
|
|
792 | if (active) ev_child_stop (w); |
|
|
793 | |
|
|
794 | ev_child_set (w, new_pid); |
|
|
795 | |
|
|
796 | if (active) ev_child_start (w); |
|
|
797 | } |
|
|
798 | } |
|
|
799 | OUTPUT: |
|
|
800 | RETVAL |
|
|
801 | |
|
|
802 | |
618 | int status (struct ev_child *w) |
803 | int rstatus (struct ev_child *w) |
|
|
804 | ALIAS: |
|
|
805 | rpid = 1 |
619 | CODE: |
806 | CODE: |
620 | RETVAL = w->status; |
807 | RETVAL = ix ? w->rpid : w->rstatus; |
621 | OUTPUT: |
808 | OUTPUT: |
622 | RETVAL |
809 | RETVAL |
623 | |
810 | |
624 | #if 0 |
811 | #ifndef _WIN32 |
625 | |
812 | |
626 | MODULE = EV PACKAGE = EV::DNS PREFIX = evdns_ |
813 | MODULE = EV PACKAGE = EV::DNS PREFIX = evdns_ |
627 | |
814 | |
628 | BOOT: |
815 | BOOT: |
629 | { |
816 | { |
… | |
… | |
700 | |
887 | |
701 | int evdns_set_option (char *option, char *val, int flags) |
888 | int evdns_set_option (char *option, char *val, int flags) |
702 | |
889 | |
703 | int evdns_resolv_conf_parse (int flags, const char *filename) |
890 | int evdns_resolv_conf_parse (int flags, const char *filename) |
704 | |
891 | |
705 | #ifdef MS_WINDOWS |
892 | #ifdef _WIN32 |
706 | |
893 | |
707 | int evdns_config_windows_nameservers () |
894 | int evdns_config_windows_nameservers () |
708 | |
895 | |
709 | #endif |
896 | #endif |
710 | |
897 | |
… | |
… | |
712 | |
899 | |
713 | void evdns_search_add (char *domain) |
900 | void evdns_search_add (char *domain) |
714 | |
901 | |
715 | void evdns_search_ndots_set (int ndots) |
902 | void evdns_search_ndots_set (int ndots) |
716 | |
903 | |
|
|
904 | #if 0 |
717 | |
905 | |
718 | MODULE = EV PACKAGE = EV::HTTP PREFIX = evhttp_ |
906 | MODULE = EV PACKAGE = EV::HTTP PREFIX = evhttp_ |
719 | |
907 | |
720 | BOOT: |
908 | BOOT: |
721 | { |
909 | { |
… | |
… | |
753 | |
941 | |
754 | #void DESTROY (struct evhttp_request *req); |
942 | #void DESTROY (struct evhttp_request *req); |
755 | |
943 | |
756 | #endif |
944 | #endif |
757 | |
945 | |
|
|
946 | #endif |
758 | |
947 | |
759 | |
948 | |
760 | |
949 | |
761 | |
950 | |
762 | |
951 | |