… | |
… | |
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 |
7 | #define TIMEOUT_NONE HUGE_VAL |
8 | #define EV_USE_EPOLL 1 |
|
|
9 | |
8 | |
10 | #define EV_PROTOTYPES 1 |
9 | #define EV_PROTOTYPES 1 |
11 | #include "EV/EVAPI.h" |
10 | #include "EV/EVAPI.h" |
12 | |
11 | |
13 | #include "libev/ev.c" |
12 | #include "libev/ev.c" |
… | |
… | |
81 | w->fh = 0; |
80 | w->fh = 0; |
82 | w->cb_sv = newSVsv (cb_sv); |
81 | w->cb_sv = newSVsv (cb_sv); |
83 | w->self = self; |
82 | w->self = self; |
84 | |
83 | |
85 | return (void *)w; |
84 | return (void *)w; |
|
|
85 | } |
|
|
86 | |
|
|
87 | static void * |
|
|
88 | e_destroy (void *w_) |
|
|
89 | { |
|
|
90 | struct ev_watcher *w = w_; |
|
|
91 | |
|
|
92 | SvREFCNT_dec (w->fh ); w->fh = 0; |
|
|
93 | SvREFCNT_dec (w->cb_sv); w->cb_sv = 0; |
86 | } |
94 | } |
87 | |
95 | |
88 | static SV * |
96 | static SV * |
89 | e_bless (struct ev_watcher *w, HV *stash) |
97 | e_bless (struct ev_watcher *w, HV *stash) |
90 | { |
98 | { |
… | |
… | |
291 | evapi.child_stop = ev_child_stop; |
299 | evapi.child_stop = ev_child_stop; |
292 | |
300 | |
293 | sv_setiv (sv, (IV)&evapi); |
301 | sv_setiv (sv, (IV)&evapi); |
294 | SvREADONLY_on (sv); |
302 | SvREADONLY_on (sv); |
295 | } |
303 | } |
|
|
304 | |
|
|
305 | pthread_atfork (ev_fork_prepare, ev_fork_parent, ev_fork_child); |
296 | } |
306 | } |
297 | |
307 | |
298 | NV ev_now () |
308 | NV ev_now () |
299 | CODE: |
309 | CODE: |
300 | RETVAL = ev_now; |
310 | RETVAL = ev_now; |
… | |
… | |
436 | void ev_io_stop (struct ev_io *w) |
446 | void ev_io_stop (struct ev_io *w) |
437 | |
447 | |
438 | void DESTROY (struct ev_io *w) |
448 | void DESTROY (struct ev_io *w) |
439 | CODE: |
449 | CODE: |
440 | ev_io_stop (w); |
450 | ev_io_stop (w); |
|
|
451 | e_destroy (w); |
441 | |
452 | |
442 | void set (struct ev_io *w, SV *fh, int events) |
453 | void set (struct ev_io *w, SV *fh, int events) |
443 | CODE: |
454 | CODE: |
444 | { |
455 | { |
445 | int active = w->active; |
456 | int active = w->active; |
… | |
… | |
498 | void ev_signal_stop (struct ev_signal *w) |
509 | void ev_signal_stop (struct ev_signal *w) |
499 | |
510 | |
500 | void DESTROY (struct ev_signal *w) |
511 | void DESTROY (struct ev_signal *w) |
501 | CODE: |
512 | CODE: |
502 | ev_signal_stop (w); |
513 | ev_signal_stop (w); |
|
|
514 | e_destroy (w); |
503 | |
515 | |
504 | void set (struct ev_signal *w, SV *signal = 0) |
516 | void set (struct ev_signal *w, SV *signal = 0) |
505 | CODE: |
517 | CODE: |
506 | { |
518 | { |
507 | Signal signum = sv_signum (signal); /* may croak here */ |
519 | Signal signum = sv_signum (signal); /* may croak here */ |
… | |
… | |
527 | CHECK_REPEAT (w->repeat); |
539 | CHECK_REPEAT (w->repeat); |
528 | |
540 | |
529 | void DESTROY (struct ev_timer *w) |
541 | void DESTROY (struct ev_timer *w) |
530 | CODE: |
542 | CODE: |
531 | ev_timer_stop (w); |
543 | ev_timer_stop (w); |
|
|
544 | e_destroy (w); |
532 | |
545 | |
533 | void set (struct ev_timer *w, NV after, NV repeat = 0.) |
546 | void set (struct ev_timer *w, NV after, NV repeat = 0.) |
534 | INIT: |
547 | INIT: |
535 | CHECK_REPEAT (repeat); |
548 | CHECK_REPEAT (repeat); |
536 | CODE: |
549 | CODE: |
… | |
… | |
550 | void ev_periodic_stop (struct ev_periodic *w) |
563 | void ev_periodic_stop (struct ev_periodic *w) |
551 | |
564 | |
552 | void DESTROY (struct ev_periodic *w) |
565 | void DESTROY (struct ev_periodic *w) |
553 | CODE: |
566 | CODE: |
554 | ev_periodic_stop (w); |
567 | ev_periodic_stop (w); |
|
|
568 | e_destroy (w); |
555 | |
569 | |
556 | void set (struct ev_periodic *w, NV at, NV interval = 0.) |
570 | void set (struct ev_periodic *w, NV at, NV interval = 0.) |
557 | INIT: |
571 | INIT: |
558 | CHECK_REPEAT (interval); |
572 | CHECK_REPEAT (interval); |
559 | CODE: |
573 | CODE: |
… | |
… | |
571 | void ev_idle_stop (struct ev_idle *w) |
585 | void ev_idle_stop (struct ev_idle *w) |
572 | |
586 | |
573 | void DESTROY (struct ev_idle *w) |
587 | void DESTROY (struct ev_idle *w) |
574 | CODE: |
588 | CODE: |
575 | ev_idle_stop (w); |
589 | ev_idle_stop (w); |
|
|
590 | e_destroy (w); |
576 | |
591 | |
577 | MODULE = EV PACKAGE = EV::Prepare PREFIX = ev_check_ |
592 | MODULE = EV PACKAGE = EV::Prepare PREFIX = ev_check_ |
578 | |
593 | |
579 | void ev_prepare_start (struct ev_prepare *w) |
594 | void ev_prepare_start (struct ev_prepare *w) |
580 | |
595 | |
581 | void ev_prepare_stop (struct ev_prepare *w) |
596 | void ev_prepare_stop (struct ev_prepare *w) |
582 | |
597 | |
583 | void DESTROY (struct ev_prepare *w) |
598 | void DESTROY (struct ev_prepare *w) |
584 | CODE: |
599 | CODE: |
585 | ev_prepare_stop (w); |
600 | ev_prepare_stop (w); |
|
|
601 | e_destroy (w); |
586 | |
602 | |
587 | MODULE = EV PACKAGE = EV::Check PREFIX = ev_check_ |
603 | MODULE = EV PACKAGE = EV::Check PREFIX = ev_check_ |
588 | |
604 | |
589 | void ev_check_start (struct ev_check *w) |
605 | void ev_check_start (struct ev_check *w) |
590 | |
606 | |
591 | void ev_check_stop (struct ev_check *w) |
607 | void ev_check_stop (struct ev_check *w) |
592 | |
608 | |
593 | void DESTROY (struct ev_check *w) |
609 | void DESTROY (struct ev_check *w) |
594 | CODE: |
610 | CODE: |
595 | ev_check_stop (w); |
611 | ev_check_stop (w); |
|
|
612 | e_destroy (w); |
596 | |
613 | |
597 | MODULE = EV PACKAGE = EV::Child PREFIX = ev_child_ |
614 | MODULE = EV PACKAGE = EV::Child PREFIX = ev_child_ |
598 | |
615 | |
599 | void ev_child_start (struct ev_child *w) |
616 | void ev_child_start (struct ev_child *w) |
600 | |
617 | |
601 | void ev_child_stop (struct ev_child *w) |
618 | void ev_child_stop (struct ev_child *w) |
602 | |
619 | |
603 | void DESTROY (struct ev_child *w) |
620 | void DESTROY (struct ev_child *w) |
604 | CODE: |
621 | CODE: |
605 | ev_child_stop (w); |
622 | ev_child_stop (w); |
|
|
623 | e_destroy (w); |
606 | |
624 | |
607 | void set (struct ev_child *w, int pid) |
625 | void set (struct ev_child *w, int pid) |
608 | CODE: |
626 | CODE: |
609 | { |
627 | { |
610 | int active = w->active; |
628 | int active = w->active; |