1 | #include "EXTERN.h" |
1 | #include "EXTERN.h" |
2 | #include "perl.h" |
2 | #include "perl.h" |
3 | #include "XSUB.h" |
3 | #include "XSUB.h" |
4 | |
4 | |
5 | /*#include <netinet/in.h>*/ |
|
|
6 | |
|
|
7 | /* fix perl api breakage */ |
5 | /* fix perl api breakage */ |
8 | #undef signal |
6 | #undef signal |
9 | #undef sigaction |
7 | #undef sigaction |
|
|
8 | |
|
|
9 | #include "schmorp.h" |
|
|
10 | |
|
|
11 | /* old API compatibility */ |
|
|
12 | static int |
|
|
13 | sv_fileno (SV *fh) |
|
|
14 | { |
|
|
15 | return s_fileno (fh, 0); |
|
|
16 | } |
10 | |
17 | |
11 | #define EV_PROTOTYPES 1 |
18 | #define EV_PROTOTYPES 1 |
12 | #define EV_USE_NANOSLEEP EV_USE_MONOTONIC |
19 | #define EV_USE_NANOSLEEP EV_USE_MONOTONIC |
13 | #define EV_H <ev.h> |
20 | #define EV_H <ev.h> |
14 | #include "EV/EVAPI.h" |
21 | #include "EV/EVAPI.h" |
… | |
… | |
24 | |
31 | |
25 | #ifndef _WIN32 |
32 | #ifndef _WIN32 |
26 | # include <pthread.h> |
33 | # include <pthread.h> |
27 | #endif |
34 | #endif |
28 | |
35 | |
29 | /* 5.10.0 */ |
|
|
30 | #ifndef SvREFCNT_inc_NN |
|
|
31 | # define SvREFCNT_inc_NN(sv) SvREFCNT_inc (sv) |
|
|
32 | #endif |
|
|
33 | |
|
|
34 | /* 5.6.x */ |
|
|
35 | #ifndef SvRV_set |
|
|
36 | # define SvRV_set(a,b) SvRV ((a)) = (b) |
|
|
37 | #endif |
|
|
38 | |
|
|
39 | #define e_loop(w) INT2PTR (struct ev_loop *, SvIVX ((w)->loop)) |
36 | #define e_loop(w) INT2PTR (struct ev_loop *, SvIVX ((w)->loop)) |
40 | |
37 | |
41 | #define WFLAG_KEEPALIVE 1 |
38 | #define WFLAG_KEEPALIVE 1 |
42 | #define WFLAG_UNREFED 2 /* has been unref'ed */ |
39 | #define WFLAG_UNREFED 2 /* has been unref'ed */ |
43 | |
40 | |
… | |
… | |
67 | REF (w); \ |
64 | REF (w); \ |
68 | ev_ ## type ## _stop (e_loop (w), w); \ |
65 | ev_ ## type ## _stop (e_loop (w), w); \ |
69 | } while (0) |
66 | } while (0) |
70 | |
67 | |
71 | #define RESET(type,w,seta) \ |
68 | #define RESET(type,w,seta) \ |
72 | do { \ |
69 | do { \ |
73 | int active = ev_is_active (w); \ |
70 | int active = ev_is_active (w); \ |
74 | if (active) STOP (type, w); \ |
71 | if (active) STOP (type, w); \ |
75 | ev_ ## type ## _set seta; \ |
72 | ev_ ## type ## _set seta; \ |
76 | if (active) START (type, w); \ |
73 | if (active) START (type, w); \ |
77 | } while (0) |
74 | } while (0) |
78 | |
75 | |
79 | typedef int Signal; |
76 | typedef int Signal; |
|
|
77 | |
|
|
78 | /* horrible... */ |
|
|
79 | #define CHECK_SIGNAL_CAN_START(w) \ |
|
|
80 | do { \ |
|
|
81 | /* dive into the internals of libev to avoid aborting in libev */ \ |
|
|
82 | if (signals [(w)->signum - 1].loop \ |
|
|
83 | && signals [(w)->signum - 1].loop != e_loop (w)) \ |
|
|
84 | croak ("unable to start signal watcher, signal %d already registered in another loop", w->signum); \ |
|
|
85 | } while (0) |
|
|
86 | |
|
|
87 | #define START_SIGNAL(w) \ |
|
|
88 | do { \ |
|
|
89 | CHECK_SIGNAL_CAN_START (w); \ |
|
|
90 | START (signal, w); \ |
|
|
91 | } while (0) \ |
|
|
92 | |
|
|
93 | #define RESET_SIGNAL(w,seta) \ |
|
|
94 | do { \ |
|
|
95 | int active = ev_is_active (w); \ |
|
|
96 | if (active) STOP (signal, w); \ |
|
|
97 | ev_ ## signal ## _set seta; \ |
|
|
98 | if (active) START_SIGNAL (w); \ |
|
|
99 | } while (0) |
80 | |
100 | |
81 | static SV *default_loop_sv; |
101 | static SV *default_loop_sv; |
82 | |
102 | |
83 | static struct EVAPI evapi; |
103 | static struct EVAPI evapi; |
84 | |
104 | |
… | |
… | |
96 | *stash_check, |
116 | *stash_check, |
97 | *stash_embed, |
117 | *stash_embed, |
98 | *stash_fork, |
118 | *stash_fork, |
99 | *stash_async; |
119 | *stash_async; |
100 | |
120 | |
101 | #ifndef SIG_SIZE |
|
|
102 | /* kudos to Slaven Rezic for the idea */ |
|
|
103 | static char sig_size [] = { SIG_NUM }; |
|
|
104 | # define SIG_SIZE (sizeof (sig_size) + 1) |
|
|
105 | #endif |
|
|
106 | |
|
|
107 | static Signal |
|
|
108 | sv_signum (SV *sig) |
|
|
109 | { |
|
|
110 | Signal signum; |
|
|
111 | |
|
|
112 | SvGETMAGIC (sig); |
|
|
113 | |
|
|
114 | for (signum = 1; signum < SIG_SIZE; ++signum) |
|
|
115 | if (strEQ (SvPV_nolen (sig), PL_sig_name [signum])) |
|
|
116 | return signum; |
|
|
117 | |
|
|
118 | signum = SvIV (sig); |
|
|
119 | |
|
|
120 | if (signum > 0 && signum < SIG_SIZE) |
|
|
121 | return signum; |
|
|
122 | |
|
|
123 | return -1; |
|
|
124 | } |
|
|
125 | |
|
|
126 | ///////////////////////////////////////////////////////////////////////////// |
121 | ///////////////////////////////////////////////////////////////////////////// |
127 | // Event |
122 | // Event |
128 | |
123 | |
129 | static void e_cb (EV_P_ ev_watcher *w, int revents); |
124 | static void e_cb (EV_P_ ev_watcher *w, int revents); |
130 | |
125 | |
131 | static int |
|
|
132 | sv_fileno (SV *fh) |
|
|
133 | { |
|
|
134 | SvGETMAGIC (fh); |
|
|
135 | |
|
|
136 | if (SvROK (fh)) |
|
|
137 | fh = SvRV (fh); |
|
|
138 | |
|
|
139 | if (SvTYPE (fh) == SVt_PVGV) |
|
|
140 | return PerlIO_fileno (IoIFP (sv_2io (fh))); |
|
|
141 | |
|
|
142 | if (SvOK (fh) && (SvIV (fh) >= 0) && (SvIV (fh) < 0x7fffffffL)) |
|
|
143 | return SvIV (fh); |
|
|
144 | |
|
|
145 | return -1; |
|
|
146 | } |
|
|
147 | |
|
|
148 | static SV * |
|
|
149 | e_get_cv (SV *cb_sv) |
|
|
150 | { |
|
|
151 | HV *st; |
|
|
152 | GV *gvp; |
|
|
153 | CV *cv = sv_2cv (cb_sv, &st, &gvp, 0); |
|
|
154 | |
|
|
155 | if (!cv) |
|
|
156 | croak ("EV watcher callback must be a CODE reference"); |
|
|
157 | |
|
|
158 | return (SV *)cv; |
|
|
159 | } |
|
|
160 | |
|
|
161 | static void * |
126 | static void * |
162 | e_new (int size, SV *cb_sv, SV *loop) |
127 | e_new (int size, SV *cb_sv, SV *loop) |
163 | { |
128 | { |
164 | SV *cv = cb_sv ? e_get_cv (cb_sv) : 0; |
129 | SV *cv = cb_sv ? s_get_cv_croak (cb_sv) : 0; |
165 | ev_watcher *w; |
130 | ev_watcher *w; |
166 | SV *self = NEWSV (0, size); |
131 | SV *self = NEWSV (0, size); |
167 | SvPOK_only (self); |
132 | SvPOK_only (self); |
168 | SvCUR_set (self, size); |
133 | SvCUR_set (self, size); |
169 | |
134 | |
… | |
… | |
421 | const_iv (EV, BACKEND_POLL) |
386 | const_iv (EV, BACKEND_POLL) |
422 | const_iv (EV, BACKEND_EPOLL) |
387 | const_iv (EV, BACKEND_EPOLL) |
423 | const_iv (EV, BACKEND_KQUEUE) |
388 | const_iv (EV, BACKEND_KQUEUE) |
424 | const_iv (EV, BACKEND_DEVPOLL) |
389 | const_iv (EV, BACKEND_DEVPOLL) |
425 | const_iv (EV, BACKEND_PORT) |
390 | const_iv (EV, BACKEND_PORT) |
|
|
391 | const_iv (EV, BACKEND_ALL) |
426 | const_iv (EV, FLAG_AUTO) |
392 | const_iv (EV, FLAG_AUTO) |
|
|
393 | const_iv (EV, FLAG_FORKCHECK) |
|
|
394 | const_iv (EV, FLAG_SIGNALFD) |
427 | const_iv (EV, FLAG_NOENV) |
395 | const_iv (EV, FLAG_NOENV) |
|
|
396 | const_iv (EV, FLAG_NOSIGFD) /* compatibility, always 0 */ |
428 | const_iv (EV, FLAG_FORKCHECK) |
397 | const_iv (EV, FLAG_NOINOTIFY) |
429 | |
398 | |
430 | const_iv (EV_, VERSION_MAJOR) |
399 | const_iv (EV_, VERSION_MAJOR) |
431 | const_iv (EV_, VERSION_MINOR) |
400 | const_iv (EV_, VERSION_MINOR) |
432 | }; |
401 | }; |
433 | |
402 | |
… | |
… | |
455 | |
424 | |
456 | /* the poor man's shared library emulator */ |
425 | /* the poor man's shared library emulator */ |
457 | evapi.ver = EV_API_VERSION; |
426 | evapi.ver = EV_API_VERSION; |
458 | evapi.rev = EV_API_REVISION; |
427 | evapi.rev = EV_API_REVISION; |
459 | evapi.sv_fileno = sv_fileno; |
428 | evapi.sv_fileno = sv_fileno; |
460 | evapi.sv_signum = sv_signum; |
429 | evapi.sv_signum = s_signum; |
461 | evapi.supported_backends = ev_supported_backends (); |
430 | evapi.supported_backends = ev_supported_backends (); |
462 | evapi.recommended_backends = ev_recommended_backends (); |
431 | evapi.recommended_backends = ev_recommended_backends (); |
463 | evapi.embeddable_backends = ev_embeddable_backends (); |
432 | evapi.embeddable_backends = ev_embeddable_backends (); |
464 | evapi.time_ = ev_time; |
433 | evapi.time_ = ev_time; |
465 | evapi.sleep_ = ev_sleep; |
434 | evapi.sleep_ = ev_sleep; |
466 | evapi.loop_new = ev_loop_new; |
435 | evapi.loop_new = ev_loop_new; |
467 | evapi.loop_destroy = ev_loop_destroy; |
436 | evapi.loop_destroy = ev_loop_destroy; |
468 | evapi.loop_fork = ev_loop_fork; |
437 | evapi.loop_fork = ev_loop_fork; |
469 | evapi.loop_count = ev_loop_count; |
438 | evapi.loop_count = ev_loop_count; |
470 | evapi.loop_depth = ev_loop_depth; |
439 | evapi.loop_depth = ev_loop_depth; |
|
|
440 | evapi.set_userdata = ev_set_userdata; |
|
|
441 | evapi.userdata = ev_userdata; |
471 | evapi.now = ev_now; |
442 | evapi.now = ev_now; |
472 | evapi.now_update = ev_now_update; |
443 | evapi.now_update = ev_now_update; |
473 | evapi.suspend = ev_suspend; |
444 | evapi.suspend = ev_suspend; |
474 | evapi.resume = ev_resume; |
445 | evapi.resume = ev_resume; |
475 | evapi.backend = ev_backend; |
446 | evapi.backend = ev_backend; |
476 | evapi.unloop = ev_unloop; |
447 | evapi.unloop = ev_unloop; |
|
|
448 | evapi.invoke_pending = ev_invoke_pending; |
|
|
449 | evapi.pending_count = ev_pending_count; |
|
|
450 | evapi.set_loop_release_cb = ev_set_loop_release_cb; |
|
|
451 | evapi.set_invoke_pending_cb= ev_set_invoke_pending_cb; |
477 | evapi.ref = ev_ref; |
452 | evapi.ref = ev_ref; |
478 | evapi.unref = ev_unref; |
453 | evapi.unref = ev_unref; |
479 | evapi.loop = ev_loop; |
454 | evapi.loop = ev_loop; |
480 | evapi.once = ev_once; |
455 | evapi.once = ev_once; |
481 | evapi.io_start = ev_io_start; |
456 | evapi.io_start = ev_io_start; |
482 | evapi.io_stop = ev_io_stop; |
457 | evapi.io_stop = ev_io_stop; |
483 | evapi.timer_start = ev_timer_start; |
458 | evapi.timer_start = ev_timer_start; |
484 | evapi.timer_stop = ev_timer_stop; |
459 | evapi.timer_stop = ev_timer_stop; |
485 | evapi.timer_again = ev_timer_again; |
460 | evapi.timer_again = ev_timer_again; |
|
|
461 | evapi.timer_remaining = ev_timer_remaining; |
486 | evapi.periodic_start = ev_periodic_start; |
462 | evapi.periodic_start = ev_periodic_start; |
487 | evapi.periodic_stop = ev_periodic_stop; |
463 | evapi.periodic_stop = ev_periodic_stop; |
488 | evapi.signal_start = ev_signal_start; |
464 | evapi.signal_start = ev_signal_start; |
489 | evapi.signal_stop = ev_signal_stop; |
465 | evapi.signal_stop = ev_signal_stop; |
490 | evapi.idle_start = ev_idle_start; |
466 | evapi.idle_start = ev_idle_start; |
… | |
… | |
591 | C_ARGS: evapi.default_loop, fd, revents |
567 | C_ARGS: evapi.default_loop, fd, revents |
592 | |
568 | |
593 | void ev_feed_signal_event (SV *signal) |
569 | void ev_feed_signal_event (SV *signal) |
594 | CODE: |
570 | CODE: |
595 | { |
571 | { |
596 | Signal signum = sv_signum (signal); |
572 | Signal signum = s_signum (signal); |
597 | CHECK_SIG (signal, signum); |
573 | CHECK_SIG (signal, signum); |
598 | |
574 | |
599 | ev_feed_signal_event (evapi.default_loop, signum); |
575 | ev_feed_signal_event (evapi.default_loop, signum); |
600 | } |
576 | } |
601 | |
577 | |
|
|
578 | unsigned int ev_pending_count () |
|
|
579 | C_ARGS: evapi.default_loop |
|
|
580 | |
|
|
581 | void ev_invoke_pending () |
|
|
582 | C_ARGS: evapi.default_loop |
|
|
583 | |
602 | ev_io *io (SV *fh, int events, SV *cb) |
584 | ev_io *io (SV *fh, int events, SV *cb) |
603 | ALIAS: |
585 | ALIAS: |
604 | io_ns = 1 |
586 | io_ns = 1 |
|
|
587 | _ae_io = 2 |
605 | CODE: |
588 | CODE: |
606 | { |
589 | { |
607 | int fd = sv_fileno (fh); |
590 | int fd = s_fileno (fh, events & EV_WRITE); |
608 | CHECK_FD (fh, fd); |
591 | CHECK_FD (fh, fd); |
|
|
592 | |
|
|
593 | if (ix == 2) |
|
|
594 | { |
|
|
595 | ix = 0; |
|
|
596 | events = events ? EV_WRITE : EV_READ; |
|
|
597 | } |
609 | |
598 | |
610 | RETVAL = e_new (sizeof (ev_io), cb, default_loop_sv); |
599 | RETVAL = e_new (sizeof (ev_io), cb, default_loop_sv); |
611 | RETVAL->fh = newSVsv (fh); |
600 | RETVAL->fh = newSVsv (fh); |
612 | ev_io_set (RETVAL, fd, events); |
601 | ev_io_set (RETVAL, fd, events); |
613 | if (!ix) START (io, RETVAL); |
602 | if (!ix) START (io, RETVAL); |
… | |
… | |
647 | ev_signal *signal (SV *signal, SV *cb) |
636 | ev_signal *signal (SV *signal, SV *cb) |
648 | ALIAS: |
637 | ALIAS: |
649 | signal_ns = 1 |
638 | signal_ns = 1 |
650 | CODE: |
639 | CODE: |
651 | { |
640 | { |
652 | Signal signum = sv_signum (signal); |
641 | Signal signum = s_signum (signal); |
653 | CHECK_SIG (signal, signum); |
642 | CHECK_SIG (signal, signum); |
654 | |
643 | |
655 | RETVAL = e_new (sizeof (ev_signal), cb, default_loop_sv); |
644 | RETVAL = e_new (sizeof (ev_signal), cb, default_loop_sv); |
656 | ev_signal_set (RETVAL, signum); |
645 | ev_signal_set (RETVAL, signum); |
657 | if (!ix) START (signal, RETVAL); |
646 | if (!ix) START_SIGNAL (RETVAL); |
658 | } |
647 | } |
659 | OUTPUT: |
648 | OUTPUT: |
660 | RETVAL |
649 | RETVAL |
661 | |
650 | |
662 | ev_idle *idle (SV *cb) |
651 | ev_idle *idle (SV *cb) |
… | |
… | |
748 | |
737 | |
749 | void once (SV *fh, int events, SV *timeout, SV *cb) |
738 | void once (SV *fh, int events, SV *timeout, SV *cb) |
750 | CODE: |
739 | CODE: |
751 | ev_once ( |
740 | ev_once ( |
752 | evapi.default_loop, |
741 | evapi.default_loop, |
753 | sv_fileno (fh), events, |
742 | s_fileno (fh, events & EV_WRITE), events, |
754 | SvOK (timeout) ? SvNV (timeout) : -1., |
743 | SvOK (timeout) ? SvNV (timeout) : -1., |
755 | e_once_cb, |
744 | e_once_cb, |
756 | newSVsv (cb) |
745 | newSVsv (cb) |
757 | ); |
746 | ); |
758 | |
747 | |
… | |
… | |
792 | SV *cb (ev_watcher *w, SV *new_cb = 0) |
781 | SV *cb (ev_watcher *w, SV *new_cb = 0) |
793 | CODE: |
782 | CODE: |
794 | { |
783 | { |
795 | if (items > 1) |
784 | if (items > 1) |
796 | { |
785 | { |
797 | new_cb = e_get_cv (new_cb); |
786 | new_cb = s_get_cv_croak (new_cb); |
798 | RETVAL = newRV_noinc (w->cb_sv); |
787 | RETVAL = newRV_noinc (w->cb_sv); |
799 | w->cb_sv = SvREFCNT_inc (new_cb); |
788 | w->cb_sv = SvREFCNT_inc (new_cb); |
800 | } |
789 | } |
801 | else |
790 | else |
802 | RETVAL = newRV_inc (w->cb_sv); |
791 | RETVAL = newRV_inc (w->cb_sv); |
… | |
… | |
872 | e_destroy (w); |
861 | e_destroy (w); |
873 | |
862 | |
874 | void set (ev_io *w, SV *fh, int events) |
863 | void set (ev_io *w, SV *fh, int events) |
875 | CODE: |
864 | CODE: |
876 | { |
865 | { |
877 | int fd = sv_fileno (fh); |
866 | int fd = s_fileno (fh, events & EV_WRITE); |
878 | CHECK_FD (fh, fd); |
867 | CHECK_FD (fh, fd); |
879 | |
868 | |
880 | sv_setsv (w->fh, fh); |
869 | sv_setsv (w->fh, fh); |
881 | RESET (io, w, (w, fd, events)); |
870 | RESET (io, w, (w, fd, events)); |
882 | } |
871 | } |
… | |
… | |
884 | SV *fh (ev_io *w, SV *new_fh = 0) |
873 | SV *fh (ev_io *w, SV *new_fh = 0) |
885 | CODE: |
874 | CODE: |
886 | { |
875 | { |
887 | if (items > 1) |
876 | if (items > 1) |
888 | { |
877 | { |
889 | int fd = sv_fileno (new_fh); |
878 | int fd = s_fileno (new_fh, w->events & EV_WRITE); |
890 | CHECK_FD (new_fh, fd); |
879 | CHECK_FD (new_fh, fd); |
891 | |
880 | |
892 | RETVAL = w->fh; |
881 | RETVAL = w->fh; |
893 | w->fh = newSVsv (new_fh); |
882 | w->fh = newSVsv (new_fh); |
894 | |
883 | |
… | |
… | |
913 | |
902 | |
914 | MODULE = EV PACKAGE = EV::Signal PREFIX = ev_signal_ |
903 | MODULE = EV PACKAGE = EV::Signal PREFIX = ev_signal_ |
915 | |
904 | |
916 | void ev_signal_start (ev_signal *w) |
905 | void ev_signal_start (ev_signal *w) |
917 | CODE: |
906 | CODE: |
918 | START (signal, w); |
907 | START_SIGNAL (w); |
919 | |
908 | |
920 | void ev_signal_stop (ev_signal *w) |
909 | void ev_signal_stop (ev_signal *w) |
921 | CODE: |
910 | CODE: |
922 | STOP (signal, w); |
911 | STOP (signal, w); |
923 | |
912 | |
… | |
… | |
927 | e_destroy (w); |
916 | e_destroy (w); |
928 | |
917 | |
929 | void set (ev_signal *w, SV *signal) |
918 | void set (ev_signal *w, SV *signal) |
930 | CODE: |
919 | CODE: |
931 | { |
920 | { |
932 | Signal signum = sv_signum (signal); |
921 | Signal signum = s_signum (signal); |
933 | CHECK_SIG (signal, signum); |
922 | CHECK_SIG (signal, signum); |
934 | |
923 | |
935 | RESET (signal, w, (w, signum)); |
924 | RESET_SIGNAL (w, (w, signum)); |
936 | } |
925 | } |
937 | |
926 | |
938 | int signal (ev_signal *w, SV *new_signal = 0) |
927 | int signal (ev_signal *w, SV *new_signal = 0) |
939 | CODE: |
928 | CODE: |
940 | { |
929 | { |
941 | RETVAL = w->signum; |
930 | RETVAL = w->signum; |
942 | |
931 | |
943 | if (items > 1) |
932 | if (items > 1) |
944 | { |
933 | { |
945 | Signal signum = sv_signum (new_signal); |
934 | Signal signum = s_signum (new_signal); |
946 | CHECK_SIG (new_signal, signum); |
935 | CHECK_SIG (new_signal, signum); |
947 | |
936 | |
948 | RESET (signal, w, (w, signum)); |
937 | RESET_SIGNAL (w, (w, signum)); |
949 | } |
938 | } |
950 | } |
939 | } |
951 | OUTPUT: |
940 | OUTPUT: |
952 | RETVAL |
941 | RETVAL |
953 | |
942 | |
… | |
… | |
967 | INIT: |
956 | INIT: |
968 | CHECK_REPEAT (w->repeat); |
957 | CHECK_REPEAT (w->repeat); |
969 | CODE: |
958 | CODE: |
970 | ev_timer_again (e_loop (w), w); |
959 | ev_timer_again (e_loop (w), w); |
971 | UNREF (w); |
960 | UNREF (w); |
|
|
961 | |
|
|
962 | NV ev_timer_remaining (ev_timer *w) |
|
|
963 | C_ARGS: e_loop (w), w |
972 | |
964 | |
973 | void DESTROY (ev_timer *w) |
965 | void DESTROY (ev_timer *w) |
974 | CODE: |
966 | CODE: |
975 | STOP (timer, w); |
967 | STOP (timer, w); |
976 | e_destroy (w); |
968 | e_destroy (w); |
… | |
… | |
1305 | |
1297 | |
1306 | void ev_unloop (struct ev_loop *loop, int how = 1) |
1298 | void ev_unloop (struct ev_loop *loop, int how = 1) |
1307 | |
1299 | |
1308 | void ev_feed_fd_event (struct ev_loop *loop, int fd, int revents = EV_NONE) |
1300 | void ev_feed_fd_event (struct ev_loop *loop, int fd, int revents = EV_NONE) |
1309 | |
1301 | |
|
|
1302 | unsigned int ev_pending_count (struct ev_loop *loop) |
|
|
1303 | |
|
|
1304 | void ev_invoke_pending (struct ev_loop *loop) |
|
|
1305 | |
1310 | #if 0 |
1306 | #if 0 |
1311 | |
1307 | |
1312 | void ev_feed_signal_event (struct ev_loop *loop, SV *signal) |
1308 | void ev_feed_signal_event (struct ev_loop *loop, SV *signal) |
1313 | CODE: |
1309 | CODE: |
1314 | { |
1310 | { |
1315 | Signal signum = sv_signum (signal); |
1311 | Signal signum = s_signum (signal); |
1316 | CHECK_SIG (signal, signum); |
1312 | CHECK_SIG (signal, signum); |
1317 | |
1313 | |
1318 | ev_feed_signal_event (loop, signum); |
1314 | ev_feed_signal_event (loop, signum); |
1319 | } |
1315 | } |
1320 | |
1316 | |
… | |
… | |
1323 | ev_io *io (struct ev_loop *loop, SV *fh, int events, SV *cb) |
1319 | ev_io *io (struct ev_loop *loop, SV *fh, int events, SV *cb) |
1324 | ALIAS: |
1320 | ALIAS: |
1325 | io_ns = 1 |
1321 | io_ns = 1 |
1326 | CODE: |
1322 | CODE: |
1327 | { |
1323 | { |
1328 | int fd = sv_fileno (fh); |
1324 | int fd = s_fileno (fh, events & EV_WRITE); |
1329 | CHECK_FD (fh, fd); |
1325 | CHECK_FD (fh, fd); |
1330 | |
1326 | |
1331 | RETVAL = e_new (sizeof (ev_io), cb, ST (0)); |
1327 | RETVAL = e_new (sizeof (ev_io), cb, ST (0)); |
1332 | RETVAL->fh = newSVsv (fh); |
1328 | RETVAL->fh = newSVsv (fh); |
1333 | ev_io_set (RETVAL, fd, events); |
1329 | ev_io_set (RETVAL, fd, events); |
… | |
… | |
1363 | if (!ix) START (periodic, w); |
1359 | if (!ix) START (periodic, w); |
1364 | } |
1360 | } |
1365 | OUTPUT: |
1361 | OUTPUT: |
1366 | RETVAL |
1362 | RETVAL |
1367 | |
1363 | |
1368 | #if 0 |
|
|
1369 | |
|
|
1370 | ev_signal *signal (struct ev_loop *loop, SV *signal, SV *cb) |
1364 | ev_signal *signal (struct ev_loop *loop, SV *signal, SV *cb) |
1371 | ALIAS: |
1365 | ALIAS: |
1372 | signal_ns = 1 |
1366 | signal_ns = 1 |
1373 | CODE: |
1367 | CODE: |
1374 | { |
1368 | { |
1375 | Signal signum = sv_signum (signal); |
1369 | Signal signum = s_signum (signal); |
1376 | CHECK_SIG (signal, signum); |
1370 | CHECK_SIG (signal, signum); |
1377 | |
1371 | |
1378 | RETVAL = e_new (sizeof (ev_signal), cb, ST (0)); |
1372 | RETVAL = e_new (sizeof (ev_signal), cb, ST (0)); |
1379 | ev_signal_set (RETVAL, signum); |
1373 | ev_signal_set (RETVAL, signum); |
1380 | if (!ix) START (signal, RETVAL); |
1374 | if (!ix) START_SIGNAL (RETVAL); |
1381 | } |
1375 | } |
1382 | OUTPUT: |
1376 | OUTPUT: |
1383 | RETVAL |
1377 | RETVAL |
1384 | |
|
|
1385 | #endif |
|
|
1386 | |
1378 | |
1387 | ev_idle *idle (struct ev_loop *loop, SV *cb) |
1379 | ev_idle *idle (struct ev_loop *loop, SV *cb) |
1388 | ALIAS: |
1380 | ALIAS: |
1389 | idle_ns = 1 |
1381 | idle_ns = 1 |
1390 | CODE: |
1382 | CODE: |
… | |
… | |
1473 | |
1465 | |
1474 | void once (struct ev_loop *loop, SV *fh, int events, SV *timeout, SV *cb) |
1466 | void once (struct ev_loop *loop, SV *fh, int events, SV *timeout, SV *cb) |
1475 | CODE: |
1467 | CODE: |
1476 | ev_once ( |
1468 | ev_once ( |
1477 | loop, |
1469 | loop, |
1478 | sv_fileno (fh), events, |
1470 | s_fileno (fh, events & EV_WRITE), events, |
1479 | SvOK (timeout) ? SvNV (timeout) : -1., |
1471 | SvOK (timeout) ? SvNV (timeout) : -1., |
1480 | e_once_cb, |
1472 | e_once_cb, |
1481 | newSVsv (cb) |
1473 | newSVsv (cb) |
1482 | ); |
1474 | ); |
1483 | |
1475 | |