… | |
… | |
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 | |
13 | #include "libev/ev.c" |
10 | #include "libev/ev.c" |
|
|
11 | #include "libev/event.h" |
|
|
12 | #include "libev/event.c" |
|
|
13 | #include "libev/evdns.c" |
14 | |
14 | |
15 | typedef int Signal; |
15 | typedef int Signal; |
16 | |
16 | |
17 | static struct EVAPI evapi; |
17 | static struct EVAPI evapi; |
18 | |
18 | |
… | |
… | |
83 | w->self = self; |
83 | w->self = self; |
84 | |
84 | |
85 | return (void *)w; |
85 | return (void *)w; |
86 | } |
86 | } |
87 | |
87 | |
|
|
88 | static void * |
|
|
89 | e_destroy (void *w_) |
|
|
90 | { |
|
|
91 | struct ev_watcher *w = w_; |
|
|
92 | |
|
|
93 | SvREFCNT_dec (w->fh ); w->fh = 0; |
|
|
94 | SvREFCNT_dec (w->cb_sv); w->cb_sv = 0; |
|
|
95 | } |
|
|
96 | |
88 | static SV * |
97 | static SV * |
89 | e_bless (struct ev_watcher *w, HV *stash) |
98 | e_bless (struct ev_watcher *w, HV *stash) |
90 | { |
99 | { |
91 | SV *rv; |
100 | SV *rv; |
92 | |
101 | |
… | |
… | |
147 | call_sv (get_sv ("EV::DIED", 1), G_DISCARD | G_VOID | G_EVAL | G_KEEPERR); |
156 | call_sv (get_sv ("EV::DIED", 1), G_DISCARD | G_VOID | G_EVAL | G_KEEPERR); |
148 | SP = PL_stack_base + mark; PUTBACK; |
157 | SP = PL_stack_base + mark; PUTBACK; |
149 | } |
158 | } |
150 | } |
159 | } |
151 | |
160 | |
152 | #if 0 |
|
|
153 | ///////////////////////////////////////////////////////////////////////////// |
161 | ///////////////////////////////////////////////////////////////////////////// |
154 | // DNS |
162 | // DNS |
155 | |
163 | |
156 | static void |
164 | static void |
157 | dns_cb (int result, char type, int count, int ttl, void *addresses, void *arg) |
165 | dns_cb (int result, char type, int count, int ttl, void *addresses, void *arg) |
… | |
… | |
199 | call_sv (get_sv ("EV::DIED", 1), G_DISCARD | G_VOID | G_EVAL | G_KEEPERR); |
207 | call_sv (get_sv ("EV::DIED", 1), G_DISCARD | G_VOID | G_EVAL | G_KEEPERR); |
200 | } |
208 | } |
201 | |
209 | |
202 | LEAVE; |
210 | LEAVE; |
203 | } |
211 | } |
204 | #endif |
|
|
205 | |
212 | |
206 | #define CHECK_REPEAT(repeat) if (repeat < 0.) \ |
213 | #define CHECK_REPEAT(repeat) if (repeat < 0.) \ |
207 | croak (# repeat " value must be >= 0"); |
214 | croak (# repeat " value must be >= 0"); |
208 | |
215 | |
209 | #define CHECK_FD(fh,fd) if ((fd) < 0) \ |
216 | #define CHECK_FD(fh,fd) if ((fd) < 0) \ |
… | |
… | |
438 | void ev_io_stop (struct ev_io *w) |
445 | void ev_io_stop (struct ev_io *w) |
439 | |
446 | |
440 | void DESTROY (struct ev_io *w) |
447 | void DESTROY (struct ev_io *w) |
441 | CODE: |
448 | CODE: |
442 | ev_io_stop (w); |
449 | ev_io_stop (w); |
|
|
450 | e_destroy (w); |
443 | |
451 | |
444 | void set (struct ev_io *w, SV *fh, int events) |
452 | void set (struct ev_io *w, SV *fh, int events) |
445 | CODE: |
453 | CODE: |
446 | { |
454 | { |
447 | int active = w->active; |
455 | int active = w->active; |
… | |
… | |
473 | } |
481 | } |
474 | } |
482 | } |
475 | OUTPUT: |
483 | OUTPUT: |
476 | RETVAL |
484 | RETVAL |
477 | |
485 | |
478 | short events (struct ev_io *w, short new_events = EV_UNDEF) |
486 | int events (struct ev_io *w, int new_events = EV_UNDEF) |
479 | CODE: |
487 | CODE: |
480 | { |
488 | { |
481 | RETVAL = w->events; |
489 | RETVAL = w->events; |
482 | |
490 | |
483 | if (items > 1) |
491 | if (items > 1) |
… | |
… | |
500 | void ev_signal_stop (struct ev_signal *w) |
508 | void ev_signal_stop (struct ev_signal *w) |
501 | |
509 | |
502 | void DESTROY (struct ev_signal *w) |
510 | void DESTROY (struct ev_signal *w) |
503 | CODE: |
511 | CODE: |
504 | ev_signal_stop (w); |
512 | ev_signal_stop (w); |
|
|
513 | e_destroy (w); |
505 | |
514 | |
506 | void set (struct ev_signal *w, SV *signal = 0) |
515 | void set (struct ev_signal *w, SV *signal = 0) |
507 | CODE: |
516 | CODE: |
508 | { |
517 | { |
509 | Signal signum = sv_signum (signal); /* may croak here */ |
518 | Signal signum = sv_signum (signal); /* may croak here */ |
… | |
… | |
529 | CHECK_REPEAT (w->repeat); |
538 | CHECK_REPEAT (w->repeat); |
530 | |
539 | |
531 | void DESTROY (struct ev_timer *w) |
540 | void DESTROY (struct ev_timer *w) |
532 | CODE: |
541 | CODE: |
533 | ev_timer_stop (w); |
542 | ev_timer_stop (w); |
|
|
543 | e_destroy (w); |
534 | |
544 | |
535 | void set (struct ev_timer *w, NV after, NV repeat = 0.) |
545 | void set (struct ev_timer *w, NV after, NV repeat = 0.) |
536 | INIT: |
546 | INIT: |
537 | CHECK_REPEAT (repeat); |
547 | CHECK_REPEAT (repeat); |
538 | CODE: |
548 | CODE: |
… | |
… | |
552 | void ev_periodic_stop (struct ev_periodic *w) |
562 | void ev_periodic_stop (struct ev_periodic *w) |
553 | |
563 | |
554 | void DESTROY (struct ev_periodic *w) |
564 | void DESTROY (struct ev_periodic *w) |
555 | CODE: |
565 | CODE: |
556 | ev_periodic_stop (w); |
566 | ev_periodic_stop (w); |
|
|
567 | e_destroy (w); |
557 | |
568 | |
558 | void set (struct ev_periodic *w, NV at, NV interval = 0.) |
569 | void set (struct ev_periodic *w, NV at, NV interval = 0.) |
559 | INIT: |
570 | INIT: |
560 | CHECK_REPEAT (interval); |
571 | CHECK_REPEAT (interval); |
561 | CODE: |
572 | CODE: |
… | |
… | |
573 | void ev_idle_stop (struct ev_idle *w) |
584 | void ev_idle_stop (struct ev_idle *w) |
574 | |
585 | |
575 | void DESTROY (struct ev_idle *w) |
586 | void DESTROY (struct ev_idle *w) |
576 | CODE: |
587 | CODE: |
577 | ev_idle_stop (w); |
588 | ev_idle_stop (w); |
|
|
589 | e_destroy (w); |
578 | |
590 | |
579 | MODULE = EV PACKAGE = EV::Prepare PREFIX = ev_check_ |
591 | MODULE = EV PACKAGE = EV::Prepare PREFIX = ev_check_ |
580 | |
592 | |
581 | void ev_prepare_start (struct ev_prepare *w) |
593 | void ev_prepare_start (struct ev_prepare *w) |
582 | |
594 | |
583 | void ev_prepare_stop (struct ev_prepare *w) |
595 | void ev_prepare_stop (struct ev_prepare *w) |
584 | |
596 | |
585 | void DESTROY (struct ev_prepare *w) |
597 | void DESTROY (struct ev_prepare *w) |
586 | CODE: |
598 | CODE: |
587 | ev_prepare_stop (w); |
599 | ev_prepare_stop (w); |
|
|
600 | e_destroy (w); |
588 | |
601 | |
589 | MODULE = EV PACKAGE = EV::Check PREFIX = ev_check_ |
602 | MODULE = EV PACKAGE = EV::Check PREFIX = ev_check_ |
590 | |
603 | |
591 | void ev_check_start (struct ev_check *w) |
604 | void ev_check_start (struct ev_check *w) |
592 | |
605 | |
593 | void ev_check_stop (struct ev_check *w) |
606 | void ev_check_stop (struct ev_check *w) |
594 | |
607 | |
595 | void DESTROY (struct ev_check *w) |
608 | void DESTROY (struct ev_check *w) |
596 | CODE: |
609 | CODE: |
597 | ev_check_stop (w); |
610 | ev_check_stop (w); |
|
|
611 | e_destroy (w); |
598 | |
612 | |
599 | MODULE = EV PACKAGE = EV::Child PREFIX = ev_child_ |
613 | MODULE = EV PACKAGE = EV::Child PREFIX = ev_child_ |
600 | |
614 | |
601 | void ev_child_start (struct ev_child *w) |
615 | void ev_child_start (struct ev_child *w) |
602 | |
616 | |
603 | void ev_child_stop (struct ev_child *w) |
617 | void ev_child_stop (struct ev_child *w) |
604 | |
618 | |
605 | void DESTROY (struct ev_child *w) |
619 | void DESTROY (struct ev_child *w) |
606 | CODE: |
620 | CODE: |
607 | ev_child_stop (w); |
621 | ev_child_stop (w); |
|
|
622 | e_destroy (w); |
608 | |
623 | |
609 | void set (struct ev_child *w, int pid) |
624 | void set (struct ev_child *w, int pid) |
610 | CODE: |
625 | CODE: |
611 | { |
626 | { |
612 | int active = w->active; |
627 | int active = w->active; |
… | |
… | |
618 | int status (struct ev_child *w) |
633 | int status (struct ev_child *w) |
619 | CODE: |
634 | CODE: |
620 | RETVAL = w->status; |
635 | RETVAL = w->status; |
621 | OUTPUT: |
636 | OUTPUT: |
622 | RETVAL |
637 | RETVAL |
623 | |
|
|
624 | #if 0 |
|
|
625 | |
638 | |
626 | MODULE = EV PACKAGE = EV::DNS PREFIX = evdns_ |
639 | MODULE = EV PACKAGE = EV::DNS PREFIX = evdns_ |
627 | |
640 | |
628 | BOOT: |
641 | BOOT: |
629 | { |
642 | { |
… | |
… | |
712 | |
725 | |
713 | void evdns_search_add (char *domain) |
726 | void evdns_search_add (char *domain) |
714 | |
727 | |
715 | void evdns_search_ndots_set (int ndots) |
728 | void evdns_search_ndots_set (int ndots) |
716 | |
729 | |
|
|
730 | #if 0 |
717 | |
731 | |
718 | MODULE = EV PACKAGE = EV::HTTP PREFIX = evhttp_ |
732 | MODULE = EV PACKAGE = EV::HTTP PREFIX = evhttp_ |
719 | |
733 | |
720 | BOOT: |
734 | BOOT: |
721 | { |
735 | { |