… | |
… | |
104 | static void |
104 | static void |
105 | e_cb (struct ev_watcher *w, int revents) |
105 | e_cb (struct ev_watcher *w, int revents) |
106 | { |
106 | { |
107 | dSP; |
107 | dSP; |
108 | I32 mark = SP - PL_stack_base; |
108 | I32 mark = SP - PL_stack_base; |
109 | SV *sv_self, *sv_events; |
109 | SV *sv_self, *sv_events, *sv_status = 0; |
110 | static SV *sv_events_cache; |
110 | static SV *sv_events_cache; |
111 | |
111 | |
112 | sv_self = newRV_inc (w->self); /* w->self MUST be blessed by now */ |
112 | sv_self = newRV_inc (w->self); /* w->self MUST be blessed by now */ |
113 | |
113 | |
114 | if (sv_events_cache) |
114 | if (sv_events_cache) |
… | |
… | |
121 | |
121 | |
122 | PUSHMARK (SP); |
122 | PUSHMARK (SP); |
123 | EXTEND (SP, 2); |
123 | EXTEND (SP, 2); |
124 | PUSHs (sv_self); |
124 | PUSHs (sv_self); |
125 | PUSHs (sv_events); |
125 | PUSHs (sv_events); |
|
|
126 | |
|
|
127 | if (revents & EV_CHILD) |
|
|
128 | XPUSHs (sv_status = newSViv (((struct ev_child *)w)->status)); |
|
|
129 | |
126 | PUTBACK; |
130 | PUTBACK; |
127 | call_sv (w->cb_sv, G_DISCARD | G_VOID | G_EVAL); |
131 | call_sv (w->cb_sv, G_DISCARD | G_VOID | G_EVAL); |
128 | SP = PL_stack_base + mark; PUTBACK; |
132 | SP = PL_stack_base + mark; PUTBACK; |
129 | |
133 | |
130 | SvREFCNT_dec (sv_self); |
134 | SvREFCNT_dec (sv_self); |
|
|
135 | SvREFCNT_dec (sv_status); |
131 | |
136 | |
132 | if (sv_events_cache) |
137 | if (sv_events_cache) |
133 | SvREFCNT_dec (sv_events); |
138 | SvREFCNT_dec (sv_events); |
134 | else |
139 | else |
135 | sv_events_cache = sv_events; |
140 | sv_events_cache = sv_events; |
… | |
… | |
237 | |
242 | |
238 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
243 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
239 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
244 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
240 | |
245 | |
241 | stash_watcher = gv_stashpv ("EV::Watcher" , 1); |
246 | stash_watcher = gv_stashpv ("EV::Watcher" , 1); |
242 | stash_io = gv_stashpv ("EV::IO" , 1); |
247 | stash_io = gv_stashpv ("EV::Io" , 1); |
243 | stash_time = gv_stashpv ("EV::Time" , 1); |
248 | stash_time = gv_stashpv ("EV::Time" , 1); |
244 | stash_timer = gv_stashpv ("EV::Timer" , 1); |
249 | stash_timer = gv_stashpv ("EV::Timer" , 1); |
245 | stash_periodic = gv_stashpv ("EV::Periodic", 1); |
250 | stash_periodic = gv_stashpv ("EV::Periodic", 1); |
246 | stash_signal = gv_stashpv ("EV::Signal" , 1); |
251 | stash_signal = gv_stashpv ("EV::Signal" , 1); |
247 | stash_idle = gv_stashpv ("EV::Idle" , 1); |
252 | stash_idle = gv_stashpv ("EV::Idle" , 1); |
… | |
… | |
277 | evapi.idle_stop = evidle_stop; |
282 | evapi.idle_stop = evidle_stop; |
278 | evapi.prepare_start = evprepare_start; |
283 | evapi.prepare_start = evprepare_start; |
279 | evapi.prepare_stop = evprepare_stop; |
284 | evapi.prepare_stop = evprepare_stop; |
280 | evapi.check_start = evcheck_start; |
285 | evapi.check_start = evcheck_start; |
281 | evapi.check_stop = evcheck_stop; |
286 | evapi.check_stop = evcheck_stop; |
|
|
287 | evapi.child_start = evchild_start; |
|
|
288 | evapi.child_stop = evchild_stop; |
282 | |
289 | |
283 | sv_setiv (sv, (IV)&evapi); |
290 | sv_setiv (sv, (IV)&evapi); |
284 | SvREADONLY_on (sv); |
291 | SvREADONLY_on (sv); |
285 | } |
292 | } |
286 | } |
293 | } |
… | |
… | |
380 | evcheck_set (RETVAL); |
387 | evcheck_set (RETVAL); |
381 | if (!ix) evcheck_start (RETVAL); |
388 | if (!ix) evcheck_start (RETVAL); |
382 | OUTPUT: |
389 | OUTPUT: |
383 | RETVAL |
390 | RETVAL |
384 | |
391 | |
385 | struct ev_child *child (SV *cb, int pid) |
392 | struct ev_child *child (int pid, SV *cb) |
386 | ALIAS: |
393 | ALIAS: |
387 | check_ns = 1 |
394 | check_ns = 1 |
388 | CODE: |
395 | CODE: |
389 | RETVAL = e_new (sizeof (struct ev_check), cb); |
396 | RETVAL = e_new (sizeof (struct ev_check), cb); |
390 | evchild (RETVAL, pid); |
397 | evchild_set (RETVAL, pid); |
391 | if (!ix) evchild_start (RETVAL); |
398 | if (!ix) evchild_start (RETVAL); |
392 | OUTPUT: |
399 | OUTPUT: |
393 | RETVAL |
400 | RETVAL |
394 | |
401 | |
395 | |
402 | |
… | |
… | |
408 | sv_setsv (w->cb_sv, new_cb); |
415 | sv_setsv (w->cb_sv, new_cb); |
409 | } |
416 | } |
410 | OUTPUT: |
417 | OUTPUT: |
411 | RETVAL |
418 | RETVAL |
412 | |
419 | |
|
|
420 | void trigger (struct ev_watcher *w, int revents = EV_NONE) |
|
|
421 | CODE: |
|
|
422 | w->cb (w, revents); |
|
|
423 | |
413 | MODULE = EV PACKAGE = EV::IO PREFIX = evio_ |
424 | MODULE = EV PACKAGE = EV::Io PREFIX = evio_ |
414 | |
425 | |
415 | void evio_start (struct ev_io *w) |
426 | void evio_start (struct ev_io *w) |
416 | |
427 | |
417 | void evio_stop (struct ev_io *w) |
428 | void evio_stop (struct ev_io *w) |
|
|
429 | |
|
|
430 | void DESTROY (struct ev_io *w) |
|
|
431 | CODE: |
|
|
432 | evio_stop (w); |
418 | |
433 | |
419 | void set (struct ev_io *w, SV *fh, int events) |
434 | void set (struct ev_io *w, SV *fh, int events) |
420 | CODE: |
435 | CODE: |
421 | { |
436 | { |
422 | int active = w->active; |
437 | int active = w->active; |
… | |
… | |
469 | |
484 | |
470 | void evsignal_start (struct ev_signal *w) |
485 | void evsignal_start (struct ev_signal *w) |
471 | |
486 | |
472 | void evsignal_stop (struct ev_signal *w) |
487 | void evsignal_stop (struct ev_signal *w) |
473 | |
488 | |
|
|
489 | void DESTROY (struct ev_signal *w) |
|
|
490 | CODE: |
|
|
491 | evsignal_stop (w); |
|
|
492 | |
474 | void set (struct ev_signal *w, SV *signal = 0) |
493 | void set (struct ev_signal *w, SV *signal = 0) |
475 | CODE: |
494 | CODE: |
476 | { |
495 | { |
477 | Signal signum = sv_signum (signal); /* may croak here */ |
496 | Signal signum = sv_signum (signal); /* may croak here */ |
478 | int active = w->active; |
497 | int active = w->active; |
… | |
… | |
493 | void evtimer_stop (struct ev_timer *w) |
512 | void evtimer_stop (struct ev_timer *w) |
494 | |
513 | |
495 | void evtimer_again (struct ev_timer *w) |
514 | void evtimer_again (struct ev_timer *w) |
496 | INIT: |
515 | INIT: |
497 | CHECK_REPEAT (w->repeat); |
516 | CHECK_REPEAT (w->repeat); |
|
|
517 | |
|
|
518 | void DESTROY (struct ev_timer *w) |
|
|
519 | CODE: |
|
|
520 | evtimer_stop (w); |
498 | |
521 | |
499 | void set (struct ev_timer *w, NV after, NV repeat = 0.) |
522 | void set (struct ev_timer *w, NV after, NV repeat = 0.) |
500 | INIT: |
523 | INIT: |
501 | CHECK_REPEAT (repeat); |
524 | CHECK_REPEAT (repeat); |
502 | CODE: |
525 | CODE: |
… | |
… | |
513 | INIT: |
536 | INIT: |
514 | CHECK_REPEAT (w->interval); |
537 | CHECK_REPEAT (w->interval); |
515 | |
538 | |
516 | void evperiodic_stop (struct ev_periodic *w) |
539 | void evperiodic_stop (struct ev_periodic *w) |
517 | |
540 | |
|
|
541 | void DESTROY (struct ev_periodic *w) |
|
|
542 | CODE: |
|
|
543 | evperiodic_stop (w); |
|
|
544 | |
518 | void set (struct ev_periodic *w, NV at, NV interval = 0.) |
545 | void set (struct ev_periodic *w, NV at, NV interval = 0.) |
519 | INIT: |
546 | INIT: |
520 | CHECK_REPEAT (interval); |
547 | CHECK_REPEAT (interval); |
521 | CODE: |
548 | CODE: |
522 | { |
549 | { |
… | |
… | |
530 | |
557 | |
531 | void evidle_start (struct ev_idle *w) |
558 | void evidle_start (struct ev_idle *w) |
532 | |
559 | |
533 | void evidle_stop (struct ev_idle *w) |
560 | void evidle_stop (struct ev_idle *w) |
534 | |
561 | |
|
|
562 | void DESTROY (struct ev_idle *w) |
|
|
563 | CODE: |
|
|
564 | evidle_stop (w); |
|
|
565 | |
535 | MODULE = EV PACKAGE = EV::Prepare PREFIX = evcheck_ |
566 | MODULE = EV PACKAGE = EV::Prepare PREFIX = evcheck_ |
536 | |
567 | |
537 | void evprepare_start (struct ev_prepare *w) |
568 | void evprepare_start (struct ev_prepare *w) |
538 | |
569 | |
539 | void evprepare_stop (struct ev_prepare *w) |
570 | void evprepare_stop (struct ev_prepare *w) |
540 | |
571 | |
|
|
572 | void DESTROY (struct ev_prepare *w) |
|
|
573 | CODE: |
|
|
574 | evprepare_stop (w); |
|
|
575 | |
541 | MODULE = EV PACKAGE = EV::Check PREFIX = evcheck_ |
576 | MODULE = EV PACKAGE = EV::Check PREFIX = evcheck_ |
542 | |
577 | |
543 | void evcheck_start (struct ev_check *w) |
578 | void evcheck_start (struct ev_check *w) |
544 | |
579 | |
545 | void evcheck_stop (struct ev_check *w) |
580 | void evcheck_stop (struct ev_check *w) |
546 | |
581 | |
|
|
582 | void DESTROY (struct ev_check *w) |
|
|
583 | CODE: |
|
|
584 | evcheck_stop (w); |
|
|
585 | |
547 | MODULE = EV PACKAGE = EV::Child PREFIX = evchild_ |
586 | MODULE = EV PACKAGE = EV::Child PREFIX = evchild_ |
548 | |
587 | |
549 | void evchild_start (struct ev_child *w) |
588 | void evchild_start (struct ev_child *w) |
550 | |
589 | |
551 | void evchild_stop (struct ev_child *w) |
590 | void evchild_stop (struct ev_child *w) |
|
|
591 | |
|
|
592 | void DESTROY (struct ev_child *w) |
|
|
593 | CODE: |
|
|
594 | evchild_stop (w); |
552 | |
595 | |
553 | void set (struct ev_child *w, int pid) |
596 | void set (struct ev_child *w, int pid) |
554 | CODE: |
597 | CODE: |
555 | { |
598 | { |
556 | int active = w->active; |
599 | int active = w->active; |
557 | if (active) evchild_stop (w); |
600 | if (active) evchild_stop (w); |
558 | evchild_set (w, pid); |
601 | evchild_set (w, pid); |
559 | if (active) evchild_start (w); |
602 | if (active) evchild_start (w); |
560 | } |
603 | } |
|
|
604 | |
|
|
605 | int status (struct ev_child *w) |
|
|
606 | CODE: |
|
|
607 | RETVAL = w->status; |
|
|
608 | OUTPUT: |
|
|
609 | RETVAL |
561 | |
610 | |
562 | #if 0 |
611 | #if 0 |
563 | |
612 | |
564 | MODULE = EV PACKAGE = EV::DNS PREFIX = evdns_ |
613 | MODULE = EV PACKAGE = EV::DNS PREFIX = evdns_ |
565 | |
614 | |