… | |
… | |
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 | |
… | |
… | |
156 | 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); |
157 | SP = PL_stack_base + mark; PUTBACK; |
157 | SP = PL_stack_base + mark; PUTBACK; |
158 | } |
158 | } |
159 | } |
159 | } |
160 | |
160 | |
161 | #if 0 |
|
|
162 | ///////////////////////////////////////////////////////////////////////////// |
161 | ///////////////////////////////////////////////////////////////////////////// |
163 | // DNS |
162 | // DNS |
164 | |
163 | |
165 | static void |
164 | static void |
166 | 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) |
… | |
… | |
208 | 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); |
209 | } |
208 | } |
210 | |
209 | |
211 | LEAVE; |
210 | LEAVE; |
212 | } |
211 | } |
213 | #endif |
|
|
214 | |
212 | |
215 | #define CHECK_REPEAT(repeat) if (repeat < 0.) \ |
213 | #define CHECK_REPEAT(repeat) if (repeat < 0.) \ |
216 | croak (# repeat " value must be >= 0"); |
214 | croak (# repeat " value must be >= 0"); |
217 | |
215 | |
218 | #define CHECK_FD(fh,fd) if ((fd) < 0) \ |
216 | #define CHECK_FD(fh,fd) if ((fd) < 0) \ |
… | |
… | |
483 | } |
481 | } |
484 | } |
482 | } |
485 | OUTPUT: |
483 | OUTPUT: |
486 | RETVAL |
484 | RETVAL |
487 | |
485 | |
488 | short events (struct ev_io *w, short new_events = EV_UNDEF) |
486 | int events (struct ev_io *w, int new_events = EV_UNDEF) |
489 | CODE: |
487 | CODE: |
490 | { |
488 | { |
491 | RETVAL = w->events; |
489 | RETVAL = w->events; |
492 | |
490 | |
493 | if (items > 1) |
491 | if (items > 1) |
… | |
… | |
512 | void DESTROY (struct ev_signal *w) |
510 | void DESTROY (struct ev_signal *w) |
513 | CODE: |
511 | CODE: |
514 | ev_signal_stop (w); |
512 | ev_signal_stop (w); |
515 | e_destroy (w); |
513 | e_destroy (w); |
516 | |
514 | |
517 | void set (struct ev_signal *w, SV *signal = 0) |
515 | void set (struct ev_signal *w, SV *signal) |
518 | CODE: |
516 | CODE: |
519 | { |
517 | { |
520 | Signal signum = sv_signum (signal); /* may croak here */ |
518 | Signal signum = sv_signum (signal); /* may croak here */ |
521 | int active = w->active; |
519 | int active = w->active; |
522 | |
520 | |
523 | if (active) ev_signal_stop (w); |
521 | if (active) ev_signal_stop (w); |
|
|
522 | |
524 | ev_signal_set (w, signum); |
523 | ev_signal_set (w, signum); |
|
|
524 | |
525 | if (active) ev_signal_start (w); |
525 | if (active) ev_signal_start (w); |
526 | } |
526 | } |
|
|
527 | |
|
|
528 | int signal (struct ev_signal *w, SV *new_signal = 0) |
|
|
529 | CODE: |
|
|
530 | { |
|
|
531 | RETVAL = w->signum; |
|
|
532 | |
|
|
533 | if (items > 1) |
|
|
534 | { |
|
|
535 | Signal signum = sv_signum (new_signal); /* may croak here */ |
|
|
536 | int active = w->active; |
|
|
537 | if (active) ev_signal_stop (w); |
|
|
538 | |
|
|
539 | ev_signal_set (w, signum); |
|
|
540 | |
|
|
541 | if (active) ev_signal_start (w); |
|
|
542 | } |
|
|
543 | } |
|
|
544 | OUTPUT: |
|
|
545 | RETVAL |
527 | |
546 | |
528 | MODULE = EV PACKAGE = EV::Time |
547 | MODULE = EV PACKAGE = EV::Time |
529 | |
548 | |
530 | MODULE = EV PACKAGE = EV::Timer PREFIX = ev_timer_ |
549 | MODULE = EV PACKAGE = EV::Timer PREFIX = ev_timer_ |
531 | |
550 | |
… | |
… | |
573 | CHECK_REPEAT (interval); |
592 | CHECK_REPEAT (interval); |
574 | CODE: |
593 | CODE: |
575 | { |
594 | { |
576 | int active = w->active; |
595 | int active = w->active; |
577 | if (active) ev_periodic_stop (w); |
596 | if (active) ev_periodic_stop (w); |
|
|
597 | |
578 | ev_periodic_set (w, at, interval); |
598 | ev_periodic_set (w, at, interval); |
|
|
599 | |
579 | if (active) ev_periodic_start (w); |
600 | if (active) ev_periodic_start (w); |
580 | } |
601 | } |
581 | |
602 | |
582 | MODULE = EV PACKAGE = EV::Idle PREFIX = ev_idle_ |
603 | MODULE = EV PACKAGE = EV::Idle PREFIX = ev_idle_ |
583 | |
604 | |
… | |
… | |
626 | void set (struct ev_child *w, int pid) |
647 | void set (struct ev_child *w, int pid) |
627 | CODE: |
648 | CODE: |
628 | { |
649 | { |
629 | int active = w->active; |
650 | int active = w->active; |
630 | if (active) ev_child_stop (w); |
651 | if (active) ev_child_stop (w); |
|
|
652 | |
631 | ev_child_set (w, pid); |
653 | ev_child_set (w, pid); |
|
|
654 | |
632 | if (active) ev_child_start (w); |
655 | if (active) ev_child_start (w); |
633 | } |
656 | } |
634 | |
657 | |
|
|
658 | int pid (struct ev_child *w, int new_pid = 0) |
|
|
659 | CODE: |
|
|
660 | { |
|
|
661 | RETVAL = w->pid; |
|
|
662 | |
|
|
663 | if (items > 1) |
|
|
664 | { |
|
|
665 | int active = w->active; |
|
|
666 | if (active) ev_child_stop (w); |
|
|
667 | |
|
|
668 | ev_child_set (w, new_pid); |
|
|
669 | |
|
|
670 | if (active) ev_child_start (w); |
|
|
671 | } |
|
|
672 | } |
|
|
673 | OUTPUT: |
|
|
674 | RETVAL |
|
|
675 | |
|
|
676 | |
635 | int status (struct ev_child *w) |
677 | int status (struct ev_child *w) |
636 | CODE: |
678 | CODE: |
637 | RETVAL = w->status; |
679 | RETVAL = w->status; |
638 | OUTPUT: |
680 | OUTPUT: |
639 | RETVAL |
681 | RETVAL |
640 | |
|
|
641 | #if 0 |
|
|
642 | |
682 | |
643 | MODULE = EV PACKAGE = EV::DNS PREFIX = evdns_ |
683 | MODULE = EV PACKAGE = EV::DNS PREFIX = evdns_ |
644 | |
684 | |
645 | BOOT: |
685 | BOOT: |
646 | { |
686 | { |
… | |
… | |
729 | |
769 | |
730 | void evdns_search_add (char *domain) |
770 | void evdns_search_add (char *domain) |
731 | |
771 | |
732 | void evdns_search_ndots_set (int ndots) |
772 | void evdns_search_ndots_set (int ndots) |
733 | |
773 | |
|
|
774 | #if 0 |
734 | |
775 | |
735 | MODULE = EV PACKAGE = EV::HTTP PREFIX = evhttp_ |
776 | MODULE = EV PACKAGE = EV::HTTP PREFIX = evhttp_ |
736 | |
777 | |
737 | BOOT: |
778 | BOOT: |
738 | { |
779 | { |