… | |
… | |
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" |
… | |
… | |
83 | w->self = self; |
82 | w->self = self; |
84 | |
83 | |
85 | return (void *)w; |
84 | return (void *)w; |
86 | } |
85 | } |
87 | |
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; |
|
|
94 | } |
|
|
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 | { |
91 | SV *rv; |
99 | SV *rv; |
92 | |
100 | |
… | |
… | |
107 | { |
115 | { |
108 | dSP; |
116 | dSP; |
109 | I32 mark = SP - PL_stack_base; |
117 | I32 mark = SP - PL_stack_base; |
110 | SV *sv_self, *sv_events, *sv_status = 0; |
118 | SV *sv_self, *sv_events, *sv_status = 0; |
111 | static SV *sv_events_cache; |
119 | static SV *sv_events_cache; |
112 | |
|
|
113 | fprintf (stderr, "e_cb %p,%x\n", w, revents);//D |
|
|
114 | |
120 | |
115 | sv_self = newRV_inc (w->self); /* w->self MUST be blessed by now */ |
121 | sv_self = newRV_inc (w->self); /* w->self MUST be blessed by now */ |
116 | |
122 | |
117 | if (sv_events_cache) |
123 | if (sv_events_cache) |
118 | { |
124 | { |
… | |
… | |
293 | evapi.child_stop = ev_child_stop; |
299 | evapi.child_stop = ev_child_stop; |
294 | |
300 | |
295 | sv_setiv (sv, (IV)&evapi); |
301 | sv_setiv (sv, (IV)&evapi); |
296 | SvREADONLY_on (sv); |
302 | SvREADONLY_on (sv); |
297 | } |
303 | } |
|
|
304 | |
|
|
305 | pthread_atfork (ev_fork_prepare, ev_fork_parent, ev_fork_child); |
298 | } |
306 | } |
299 | |
307 | |
300 | NV ev_now () |
308 | NV ev_now () |
301 | CODE: |
309 | CODE: |
302 | RETVAL = ev_now; |
310 | RETVAL = ev_now; |
… | |
… | |
438 | void ev_io_stop (struct ev_io *w) |
446 | void ev_io_stop (struct ev_io *w) |
439 | |
447 | |
440 | void DESTROY (struct ev_io *w) |
448 | void DESTROY (struct ev_io *w) |
441 | CODE: |
449 | CODE: |
442 | ev_io_stop (w); |
450 | ev_io_stop (w); |
|
|
451 | e_destroy (w); |
443 | |
452 | |
444 | void set (struct ev_io *w, SV *fh, int events) |
453 | void set (struct ev_io *w, SV *fh, int events) |
445 | CODE: |
454 | CODE: |
446 | { |
455 | { |
447 | int active = w->active; |
456 | int active = w->active; |
… | |
… | |
500 | void ev_signal_stop (struct ev_signal *w) |
509 | void ev_signal_stop (struct ev_signal *w) |
501 | |
510 | |
502 | void DESTROY (struct ev_signal *w) |
511 | void DESTROY (struct ev_signal *w) |
503 | CODE: |
512 | CODE: |
504 | ev_signal_stop (w); |
513 | ev_signal_stop (w); |
|
|
514 | e_destroy (w); |
505 | |
515 | |
506 | void set (struct ev_signal *w, SV *signal = 0) |
516 | void set (struct ev_signal *w, SV *signal = 0) |
507 | CODE: |
517 | CODE: |
508 | { |
518 | { |
509 | Signal signum = sv_signum (signal); /* may croak here */ |
519 | Signal signum = sv_signum (signal); /* may croak here */ |
… | |
… | |
529 | CHECK_REPEAT (w->repeat); |
539 | CHECK_REPEAT (w->repeat); |
530 | |
540 | |
531 | void DESTROY (struct ev_timer *w) |
541 | void DESTROY (struct ev_timer *w) |
532 | CODE: |
542 | CODE: |
533 | ev_timer_stop (w); |
543 | ev_timer_stop (w); |
|
|
544 | e_destroy (w); |
534 | |
545 | |
535 | void set (struct ev_timer *w, NV after, NV repeat = 0.) |
546 | void set (struct ev_timer *w, NV after, NV repeat = 0.) |
536 | INIT: |
547 | INIT: |
537 | CHECK_REPEAT (repeat); |
548 | CHECK_REPEAT (repeat); |
538 | CODE: |
549 | CODE: |
… | |
… | |
552 | void ev_periodic_stop (struct ev_periodic *w) |
563 | void ev_periodic_stop (struct ev_periodic *w) |
553 | |
564 | |
554 | void DESTROY (struct ev_periodic *w) |
565 | void DESTROY (struct ev_periodic *w) |
555 | CODE: |
566 | CODE: |
556 | ev_periodic_stop (w); |
567 | ev_periodic_stop (w); |
|
|
568 | e_destroy (w); |
557 | |
569 | |
558 | void set (struct ev_periodic *w, NV at, NV interval = 0.) |
570 | void set (struct ev_periodic *w, NV at, NV interval = 0.) |
559 | INIT: |
571 | INIT: |
560 | CHECK_REPEAT (interval); |
572 | CHECK_REPEAT (interval); |
561 | CODE: |
573 | CODE: |
… | |
… | |
573 | void ev_idle_stop (struct ev_idle *w) |
585 | void ev_idle_stop (struct ev_idle *w) |
574 | |
586 | |
575 | void DESTROY (struct ev_idle *w) |
587 | void DESTROY (struct ev_idle *w) |
576 | CODE: |
588 | CODE: |
577 | ev_idle_stop (w); |
589 | ev_idle_stop (w); |
|
|
590 | e_destroy (w); |
578 | |
591 | |
579 | MODULE = EV PACKAGE = EV::Prepare PREFIX = ev_check_ |
592 | MODULE = EV PACKAGE = EV::Prepare PREFIX = ev_check_ |
580 | |
593 | |
581 | void ev_prepare_start (struct ev_prepare *w) |
594 | void ev_prepare_start (struct ev_prepare *w) |
582 | |
595 | |
583 | void ev_prepare_stop (struct ev_prepare *w) |
596 | void ev_prepare_stop (struct ev_prepare *w) |
584 | |
597 | |
585 | void DESTROY (struct ev_prepare *w) |
598 | void DESTROY (struct ev_prepare *w) |
586 | CODE: |
599 | CODE: |
587 | ev_prepare_stop (w); |
600 | ev_prepare_stop (w); |
|
|
601 | e_destroy (w); |
588 | |
602 | |
589 | MODULE = EV PACKAGE = EV::Check PREFIX = ev_check_ |
603 | MODULE = EV PACKAGE = EV::Check PREFIX = ev_check_ |
590 | |
604 | |
591 | void ev_check_start (struct ev_check *w) |
605 | void ev_check_start (struct ev_check *w) |
592 | |
606 | |
593 | void ev_check_stop (struct ev_check *w) |
607 | void ev_check_stop (struct ev_check *w) |
594 | |
608 | |
595 | void DESTROY (struct ev_check *w) |
609 | void DESTROY (struct ev_check *w) |
596 | CODE: |
610 | CODE: |
597 | ev_check_stop (w); |
611 | ev_check_stop (w); |
|
|
612 | e_destroy (w); |
598 | |
613 | |
599 | MODULE = EV PACKAGE = EV::Child PREFIX = ev_child_ |
614 | MODULE = EV PACKAGE = EV::Child PREFIX = ev_child_ |
600 | |
615 | |
601 | void ev_child_start (struct ev_child *w) |
616 | void ev_child_start (struct ev_child *w) |
602 | |
617 | |
603 | void ev_child_stop (struct ev_child *w) |
618 | void ev_child_stop (struct ev_child *w) |
604 | |
619 | |
605 | void DESTROY (struct ev_child *w) |
620 | void DESTROY (struct ev_child *w) |
606 | CODE: |
621 | CODE: |
607 | ev_child_stop (w); |
622 | ev_child_stop (w); |
|
|
623 | e_destroy (w); |
608 | |
624 | |
609 | void set (struct ev_child *w, int pid) |
625 | void set (struct ev_child *w, int pid) |
610 | CODE: |
626 | CODE: |
611 | { |
627 | { |
612 | int active = w->active; |
628 | int active = w->active; |