… | |
… | |
3 | #include "XSUB.h" |
3 | #include "XSUB.h" |
4 | |
4 | |
5 | /*#include <netinet/in.h>*/ |
5 | /*#include <netinet/in.h>*/ |
6 | |
6 | |
7 | #define EV_PROTOTYPES 1 |
7 | #define EV_PROTOTYPES 1 |
|
|
8 | #define EV_USE_NANOSLEEP EV_USE_MONOTONIC |
8 | #define EV_H <ev.h> |
9 | #define EV_H <ev.h> |
9 | #include "EV/EVAPI.h" |
10 | #include "EV/EVAPI.h" |
10 | |
11 | |
11 | /* fix perl api breakage */ |
12 | /* fix perl api breakage */ |
12 | #undef signal |
13 | #undef signal |
… | |
… | |
28 | #define e_loop(w) INT2PTR (struct ev_loop *, SvIVX ((w)->loop)) |
29 | #define e_loop(w) INT2PTR (struct ev_loop *, SvIVX ((w)->loop)) |
29 | |
30 | |
30 | #define WFLAG_KEEPALIVE 1 |
31 | #define WFLAG_KEEPALIVE 1 |
31 | |
32 | |
32 | #define UNREF(w) \ |
33 | #define UNREF(w) \ |
33 | if (!((w)->flags & WFLAG_KEEPALIVE) \ |
34 | if (!((w)->e_flags & WFLAG_KEEPALIVE) \ |
34 | && !ev_is_active (w)) \ |
35 | && !ev_is_active (w)) \ |
35 | ev_unref (e_loop (w)); |
36 | ev_unref (e_loop (w)); |
36 | |
37 | |
37 | #define REF(w) \ |
38 | #define REF(w) \ |
38 | if (!((w)->flags & WFLAG_KEEPALIVE) \ |
39 | if (!((w)->e_flags & WFLAG_KEEPALIVE) \ |
39 | && ev_is_active (w)) \ |
40 | && ev_is_active (w)) \ |
40 | ev_ref (e_loop (w)); |
41 | ev_ref (e_loop (w)); |
41 | |
42 | |
42 | #define START(type,w) \ |
43 | #define START(type,w) \ |
43 | do { \ |
44 | do { \ |
44 | UNREF (w); \ |
45 | UNREF (w); \ |
45 | ev_ ## type ## _start (e_loop (w), w); \ |
46 | ev_ ## type ## _start (e_loop (w), w); \ |
46 | } while (0) |
47 | } while (0) |
47 | |
48 | |
48 | #define STOP(type,w) \ |
49 | #define STOP(type,w) \ |
49 | do { \ |
50 | do { \ |
50 | REF (w); \ |
51 | REF (w); \ |
51 | ev_ ## type ## _stop (e_loop (w), w); \ |
52 | ev_ ## type ## _stop (e_loop (w), w); \ |
52 | } while (0) |
53 | } while (0) |
53 | |
54 | |
54 | #define RESET(type,w,seta) \ |
55 | #define RESET(type,w,seta) \ |
55 | do { \ |
56 | do { \ |
56 | int active = ev_is_active (w); \ |
57 | int active = ev_is_active (w); \ |
… | |
… | |
76 | *stash_stat, |
77 | *stash_stat, |
77 | *stash_idle, |
78 | *stash_idle, |
78 | *stash_prepare, |
79 | *stash_prepare, |
79 | *stash_check, |
80 | *stash_check, |
80 | *stash_embed, |
81 | *stash_embed, |
81 | *stash_fork; |
82 | *stash_fork, |
|
|
83 | *stash_async; |
82 | |
84 | |
83 | #ifndef SIG_SIZE |
85 | #ifndef SIG_SIZE |
84 | /* kudos to Slaven Rezic for the idea */ |
86 | /* kudos to Slaven Rezic for the idea */ |
85 | static char sig_size [] = { SIG_NUM }; |
87 | static char sig_size [] = { SIG_NUM }; |
86 | # define SIG_SIZE (sizeof (sig_size) + 1) |
88 | # define SIG_SIZE (sizeof (sig_size) + 1) |
… | |
… | |
137 | |
139 | |
138 | w = (ev_watcher *)SvPVX (self); |
140 | w = (ev_watcher *)SvPVX (self); |
139 | |
141 | |
140 | ev_init (w, e_cb); |
142 | ev_init (w, e_cb); |
141 | |
143 | |
142 | w->loop = SvREFCNT_inc (SvRV (loop)); |
144 | w->loop = SvREFCNT_inc (SvRV (loop)); |
143 | w->flags = WFLAG_KEEPALIVE; |
145 | w->e_flags = WFLAG_KEEPALIVE; |
144 | w->data = 0; |
146 | w->data = 0; |
145 | w->fh = 0; |
147 | w->fh = 0; |
146 | w->cb_sv = SvTEMP (cb_sv) && SvREFCNT (cb_sv) == 1 ? SvREFCNT_inc (cb_sv) : newSVsv (cb_sv); |
148 | w->cb_sv = SvTEMP (cb_sv) && SvREFCNT (cb_sv) == 1 ? SvREFCNT_inc (cb_sv) : newSVsv (cb_sv); |
147 | w->self = self; |
149 | w->self = self; |
148 | |
150 | |
149 | return (void *)w; |
151 | return (void *)w; |
150 | } |
152 | } |
151 | |
153 | |
152 | static void |
154 | static void |
… | |
… | |
374 | stash_check = gv_stashpv ("EV::Check" , 1); |
376 | stash_check = gv_stashpv ("EV::Check" , 1); |
375 | stash_child = gv_stashpv ("EV::Child" , 1); |
377 | stash_child = gv_stashpv ("EV::Child" , 1); |
376 | stash_embed = gv_stashpv ("EV::Embed" , 1); |
378 | stash_embed = gv_stashpv ("EV::Embed" , 1); |
377 | stash_stat = gv_stashpv ("EV::Stat" , 1); |
379 | stash_stat = gv_stashpv ("EV::Stat" , 1); |
378 | stash_fork = gv_stashpv ("EV::Fork" , 1); |
380 | stash_fork = gv_stashpv ("EV::Fork" , 1); |
|
|
381 | stash_async = gv_stashpv ("EV::Async" , 1); |
379 | |
382 | |
380 | { |
383 | { |
381 | SV *sv = perl_get_sv ("EV::API", TRUE); |
384 | SV *sv = perl_get_sv ("EV::API", TRUE); |
382 | perl_get_sv ("EV::API", TRUE); /* silence 5.10 warning */ |
385 | perl_get_sv ("EV::API", TRUE); /* silence 5.10 warning */ |
383 | |
386 | |
… | |
… | |
388 | evapi.sv_signum = sv_signum; |
391 | evapi.sv_signum = sv_signum; |
389 | evapi.supported_backends = ev_supported_backends (); |
392 | evapi.supported_backends = ev_supported_backends (); |
390 | evapi.recommended_backends = ev_recommended_backends (); |
393 | evapi.recommended_backends = ev_recommended_backends (); |
391 | evapi.embeddable_backends = ev_embeddable_backends (); |
394 | evapi.embeddable_backends = ev_embeddable_backends (); |
392 | evapi.time = ev_time; |
395 | evapi.time = ev_time; |
|
|
396 | evapi.sleep = ev_sleep; |
393 | evapi.loop_new = ev_loop_new; |
397 | evapi.loop_new = ev_loop_new; |
394 | evapi.loop_destroy = ev_loop_destroy; |
398 | evapi.loop_destroy = ev_loop_destroy; |
395 | evapi.loop_fork = ev_loop_fork; |
399 | evapi.loop_fork = ev_loop_fork; |
396 | evapi.loop_count = ev_loop_count; |
400 | evapi.loop_count = ev_loop_count; |
397 | evapi.now = ev_now; |
401 | evapi.now = ev_now; |
… | |
… | |
424 | evapi.embed_start = ev_embed_start; |
428 | evapi.embed_start = ev_embed_start; |
425 | evapi.embed_stop = ev_embed_stop; |
429 | evapi.embed_stop = ev_embed_stop; |
426 | evapi.embed_sweep = ev_embed_sweep; |
430 | evapi.embed_sweep = ev_embed_sweep; |
427 | evapi.fork_start = ev_fork_start; |
431 | evapi.fork_start = ev_fork_start; |
428 | evapi.fork_stop = ev_fork_stop; |
432 | evapi.fork_stop = ev_fork_stop; |
|
|
433 | evapi.async_start = ev_async_start; |
|
|
434 | evapi.async_stop = ev_async_stop; |
|
|
435 | evapi.async_send = ev_async_send; |
429 | evapi.clear_pending = ev_clear_pending; |
436 | evapi.clear_pending = ev_clear_pending; |
430 | evapi.invoke = ev_invoke; |
437 | evapi.invoke = ev_invoke; |
431 | |
438 | |
432 | sv_setiv (sv, (IV)&evapi); |
439 | sv_setiv (sv, (IV)&evapi); |
433 | SvREADONLY_on (sv); |
440 | SvREADONLY_on (sv); |
… | |
… | |
435 | #ifndef _WIN32 |
442 | #ifndef _WIN32 |
436 | pthread_atfork (0, 0, ev_default_fork); |
443 | pthread_atfork (0, 0, ev_default_fork); |
437 | #endif |
444 | #endif |
438 | } |
445 | } |
439 | |
446 | |
440 | SV *ev_default_loop (unsigned int flags = ev_supported_backends ()) |
447 | SV *ev_default_loop (unsigned int flags = 0) |
441 | CODE: |
448 | CODE: |
442 | { |
449 | { |
443 | if (!default_loop_sv) |
450 | if (!default_loop_sv) |
444 | { |
451 | { |
445 | evapi.default_loop = ev_default_loop (flags); |
452 | evapi.default_loop = ev_default_loop (flags); |
… | |
… | |
453 | RETVAL = newSVsv (default_loop_sv); |
460 | RETVAL = newSVsv (default_loop_sv); |
454 | } |
461 | } |
455 | OUTPUT: |
462 | OUTPUT: |
456 | RETVAL |
463 | RETVAL |
457 | |
464 | |
|
|
465 | void ev_default_destroy () |
|
|
466 | CODE: |
|
|
467 | ev_default_destroy (); |
|
|
468 | SvREFCNT_dec (default_loop_sv); |
|
|
469 | default_loop_sv = 0; |
|
|
470 | |
|
|
471 | unsigned int ev_supported_backends () |
|
|
472 | |
|
|
473 | unsigned int ev_recommended_backends () |
|
|
474 | |
|
|
475 | unsigned int ev_embeddable_backends () |
|
|
476 | |
458 | NV ev_time () |
477 | NV ev_time () |
459 | |
478 | |
460 | NV ev_now () |
479 | NV ev_now () |
461 | C_ARGS: evapi.default_loop |
480 | C_ARGS: evapi.default_loop |
462 | |
481 | |
… | |
… | |
464 | C_ARGS: evapi.default_loop |
483 | C_ARGS: evapi.default_loop |
465 | |
484 | |
466 | unsigned int ev_loop_count () |
485 | unsigned int ev_loop_count () |
467 | C_ARGS: evapi.default_loop |
486 | C_ARGS: evapi.default_loop |
468 | |
487 | |
|
|
488 | void ev_set_io_collect_interval (NV interval) |
|
|
489 | C_ARGS: evapi.default_loop, interval |
|
|
490 | |
|
|
491 | void ev_set_timeout_collect_interval (NV interval) |
|
|
492 | C_ARGS: evapi.default_loop, interval |
|
|
493 | |
469 | void ev_loop (int flags = 0) |
494 | void ev_loop (int flags = 0) |
470 | C_ARGS: evapi.default_loop, flags |
495 | C_ARGS: evapi.default_loop, flags |
471 | |
496 | |
472 | void ev_unloop (int how = 1) |
497 | void ev_unloop (int how = EVUNLOOP_ONE) |
473 | C_ARGS: evapi.default_loop, how |
498 | C_ARGS: evapi.default_loop, how |
474 | |
499 | |
475 | void ev_feed_fd_event (int fd, int revents = EV_NONE) |
500 | void ev_feed_fd_event (int fd, int revents = EV_NONE) |
476 | C_ARGS: evapi.default_loop, fd, revents |
501 | C_ARGS: evapi.default_loop, fd, revents |
477 | |
502 | |
… | |
… | |
582 | ev_fork_set (RETVAL); |
607 | ev_fork_set (RETVAL); |
583 | if (!ix) START (fork, RETVAL); |
608 | if (!ix) START (fork, RETVAL); |
584 | OUTPUT: |
609 | OUTPUT: |
585 | RETVAL |
610 | RETVAL |
586 | |
611 | |
587 | ev_child *child (int pid, SV *cb) |
612 | ev_child *child (int pid, int trace, SV *cb) |
588 | ALIAS: |
613 | ALIAS: |
589 | child_ns = 1 |
614 | child_ns = 1 |
590 | CODE: |
615 | CODE: |
591 | RETVAL = e_new (sizeof (ev_child), cb, default_loop_sv); |
616 | RETVAL = e_new (sizeof (ev_child), cb, default_loop_sv); |
592 | ev_child_set (RETVAL, pid); |
617 | ev_child_set (RETVAL, pid, trace); |
593 | if (!ix) START (child, RETVAL); |
618 | if (!ix) START (child, RETVAL); |
594 | OUTPUT: |
619 | OUTPUT: |
595 | RETVAL |
620 | RETVAL |
596 | |
621 | |
597 | ev_stat *stat (SV *path, NV interval, SV *cb) |
622 | ev_stat *stat (SV *path, NV interval, SV *cb) |
… | |
… | |
619 | |
644 | |
620 | if (!SvOK (cb)) ev_set_cb (RETVAL, 0); |
645 | if (!SvOK (cb)) ev_set_cb (RETVAL, 0); |
621 | |
646 | |
622 | if (!ix) START (embed, RETVAL); |
647 | if (!ix) START (embed, RETVAL); |
623 | } |
648 | } |
|
|
649 | OUTPUT: |
|
|
650 | RETVAL |
|
|
651 | |
|
|
652 | ev_async *async (SV *cb) |
|
|
653 | ALIAS: |
|
|
654 | async_ns = 1 |
|
|
655 | CODE: |
|
|
656 | RETVAL = e_new (sizeof (ev_async), cb, default_loop_sv); |
|
|
657 | ev_async_set (RETVAL); |
|
|
658 | if (!ix) START (async, RETVAL); |
624 | OUTPUT: |
659 | OUTPUT: |
625 | RETVAL |
660 | RETVAL |
626 | |
661 | |
627 | void once (SV *fh, int events, SV *timeout, SV *cb) |
662 | void once (SV *fh, int events, SV *timeout, SV *cb) |
628 | CODE: |
663 | CODE: |
… | |
… | |
652 | C_ARGS: e_loop (w), w, revents |
687 | C_ARGS: e_loop (w), w, revents |
653 | |
688 | |
654 | int keepalive (ev_watcher *w, int new_value = 0) |
689 | int keepalive (ev_watcher *w, int new_value = 0) |
655 | CODE: |
690 | CODE: |
656 | { |
691 | { |
657 | RETVAL = w->flags & WFLAG_KEEPALIVE; |
692 | RETVAL = w->e_flags & WFLAG_KEEPALIVE; |
658 | new_value = new_value ? WFLAG_KEEPALIVE : 0; |
693 | new_value = new_value ? WFLAG_KEEPALIVE : 0; |
659 | |
694 | |
660 | if (items > 1 && ((new_value ^ w->flags) & WFLAG_KEEPALIVE)) |
695 | if (items > 1 && ((new_value ^ w->e_flags) & WFLAG_KEEPALIVE)) |
661 | { |
696 | { |
662 | REF (w); |
697 | REF (w); |
663 | w->flags = (w->flags & ~WFLAG_KEEPALIVE) | new_value; |
698 | w->e_flags = (w->e_flags & ~WFLAG_KEEPALIVE) | new_value; |
664 | UNREF (w); |
699 | UNREF (w); |
665 | } |
700 | } |
666 | } |
701 | } |
667 | OUTPUT: |
702 | OUTPUT: |
668 | RETVAL |
703 | RETVAL |
… | |
… | |
687 | { |
722 | { |
688 | SvREFCNT_dec (w->data); |
723 | SvREFCNT_dec (w->data); |
689 | w->data = newSVsv (new_data); |
724 | w->data = newSVsv (new_data); |
690 | } |
725 | } |
691 | } |
726 | } |
|
|
727 | OUTPUT: |
|
|
728 | RETVAL |
|
|
729 | |
|
|
730 | SV *loop (ev_watcher *w) |
|
|
731 | CODE: |
|
|
732 | RETVAL = newRV_inc (w->loop); |
692 | OUTPUT: |
733 | OUTPUT: |
693 | RETVAL |
734 | RETVAL |
694 | |
735 | |
695 | int priority (ev_watcher *w, int new_priority = 0) |
736 | int priority (ev_watcher *w, int new_priority = 0) |
696 | CODE: |
737 | CODE: |
… | |
… | |
909 | void DESTROY (ev_idle *w) |
950 | void DESTROY (ev_idle *w) |
910 | CODE: |
951 | CODE: |
911 | STOP (idle, w); |
952 | STOP (idle, w); |
912 | e_destroy (w); |
953 | e_destroy (w); |
913 | |
954 | |
914 | MODULE = EV PACKAGE = EV::Prepare PREFIX = ev_check_ |
955 | MODULE = EV PACKAGE = EV::Prepare PREFIX = ev_prepare_ |
915 | |
956 | |
916 | void ev_prepare_start (ev_prepare *w) |
957 | void ev_prepare_start (ev_prepare *w) |
917 | CODE: |
958 | CODE: |
918 | START (prepare, w); |
959 | START (prepare, w); |
919 | |
960 | |
… | |
… | |
969 | void DESTROY (ev_child *w) |
1010 | void DESTROY (ev_child *w) |
970 | CODE: |
1011 | CODE: |
971 | STOP (child, w); |
1012 | STOP (child, w); |
972 | e_destroy (w); |
1013 | e_destroy (w); |
973 | |
1014 | |
974 | void set (ev_child *w, int pid) |
1015 | void set (ev_child *w, int pid, int trace) |
975 | CODE: |
1016 | CODE: |
976 | RESET (child, w, (w, pid)); |
1017 | RESET (child, w, (w, pid, trace)); |
977 | |
1018 | |
978 | int pid (ev_child *w, int new_pid = 0) |
|
|
979 | CODE: |
|
|
980 | { |
|
|
981 | RETVAL = w->pid; |
|
|
982 | |
|
|
983 | if (items > 1) |
|
|
984 | RESET (child, w, (w, new_pid)); |
|
|
985 | } |
|
|
986 | OUTPUT: |
|
|
987 | RETVAL |
|
|
988 | |
|
|
989 | |
|
|
990 | int rstatus (ev_child *w) |
1019 | int pid (ev_child *w) |
991 | ALIAS: |
1020 | ALIAS: |
992 | rpid = 1 |
1021 | rpid = 1 |
|
|
1022 | rstatus = 2 |
993 | CODE: |
1023 | CODE: |
994 | RETVAL = ix ? w->rpid : w->rstatus; |
1024 | RETVAL = ix == 0 ? w->pid |
|
|
1025 | : ix == 1 ? w->rpid |
|
|
1026 | : w->rstatus; |
995 | OUTPUT: |
1027 | OUTPUT: |
996 | RETVAL |
1028 | RETVAL |
997 | |
1029 | |
998 | MODULE = EV PACKAGE = EV::Stat PREFIX = ev_stat_ |
1030 | MODULE = EV PACKAGE = EV::Stat PREFIX = ev_stat_ |
999 | |
1031 | |
… | |
… | |
1109 | { |
1141 | { |
1110 | sv_setsv (w->fh, ST (1)); |
1142 | sv_setsv (w->fh, ST (1)); |
1111 | RESET (embed, w, (w, loop)); |
1143 | RESET (embed, w, (w, loop)); |
1112 | } |
1144 | } |
1113 | |
1145 | |
|
|
1146 | SV *other (ev_embed *w) |
|
|
1147 | CODE: |
|
|
1148 | RETVAL = newSVsv (w->fh); |
|
|
1149 | OUTPUT: |
|
|
1150 | RETVAL |
|
|
1151 | |
|
|
1152 | MODULE = EV PACKAGE = EV::Async PREFIX = ev_async_ |
|
|
1153 | |
|
|
1154 | void ev_async_start (ev_async *w) |
|
|
1155 | CODE: |
|
|
1156 | START (async, w); |
|
|
1157 | |
|
|
1158 | void ev_async_stop (ev_async *w) |
|
|
1159 | CODE: |
|
|
1160 | STOP (async, w); |
|
|
1161 | |
|
|
1162 | void DESTROY (ev_async *w) |
|
|
1163 | CODE: |
|
|
1164 | STOP (async, w); |
|
|
1165 | e_destroy (w); |
|
|
1166 | |
1114 | MODULE = EV PACKAGE = EV::Loop PREFIX = ev_loop_ |
1167 | MODULE = EV PACKAGE = EV::Loop PREFIX = ev_ |
1115 | |
1168 | |
1116 | SV *new (SV *klass, unsigned int flags = ev_supported_backends ()) |
1169 | SV *new (SV *klass, unsigned int flags = 0) |
1117 | CODE: |
1170 | CODE: |
1118 | { |
1171 | { |
1119 | struct ev_loop *loop = ev_loop_new (flags); |
1172 | struct ev_loop *loop = ev_loop_new (flags); |
1120 | |
1173 | |
1121 | if (!loop) |
1174 | if (!loop) |
… | |
… | |
1128 | |
1181 | |
1129 | void DESTROY (struct ev_loop *loop) |
1182 | void DESTROY (struct ev_loop *loop) |
1130 | CODE: |
1183 | CODE: |
1131 | if (loop != evapi.default_loop) /* global destruction sucks */ |
1184 | if (loop != evapi.default_loop) /* global destruction sucks */ |
1132 | ev_loop_destroy (loop); |
1185 | ev_loop_destroy (loop); |
|
|
1186 | |
|
|
1187 | void ev_loop_fork (struct ev_loop *loop) |
|
|
1188 | |
|
|
1189 | NV ev_now (struct ev_loop *loop) |
|
|
1190 | |
|
|
1191 | void ev_set_io_collect_interval (struct ev_loop *loop, NV interval) |
|
|
1192 | |
|
|
1193 | void ev_set_timeout_collect_interval (struct ev_loop *loop, NV interval) |
|
|
1194 | |
|
|
1195 | unsigned int ev_backend (struct ev_loop *loop) |
|
|
1196 | |
|
|
1197 | unsigned int ev_loop_count (struct ev_loop *loop) |
|
|
1198 | |
|
|
1199 | void ev_loop (struct ev_loop *loop, int flags = 0) |
|
|
1200 | |
|
|
1201 | void ev_unloop (struct ev_loop *loop, int how = 1) |
|
|
1202 | |
|
|
1203 | void ev_feed_fd_event (struct ev_loop *loop, int fd, int revents = EV_NONE) |
|
|
1204 | |
|
|
1205 | #if 0 |
|
|
1206 | |
|
|
1207 | void ev_feed_signal_event (struct ev_loop *loop, SV *signal) |
|
|
1208 | CODE: |
|
|
1209 | { |
|
|
1210 | Signal signum = sv_signum (signal); |
|
|
1211 | CHECK_SIG (signal, signum); |
|
|
1212 | |
|
|
1213 | ev_feed_signal_event (loop, signum); |
|
|
1214 | } |
|
|
1215 | |
|
|
1216 | #endif |
1133 | |
1217 | |
1134 | ev_io *io (struct ev_loop *loop, SV *fh, int events, SV *cb) |
1218 | ev_io *io (struct ev_loop *loop, SV *fh, int events, SV *cb) |
1135 | ALIAS: |
1219 | ALIAS: |
1136 | io_ns = 1 |
1220 | io_ns = 1 |
1137 | CODE: |
1221 | CODE: |
… | |
… | |
1145 | if (!ix) START (io, RETVAL); |
1229 | if (!ix) START (io, RETVAL); |
1146 | } |
1230 | } |
1147 | OUTPUT: |
1231 | OUTPUT: |
1148 | RETVAL |
1232 | RETVAL |
1149 | |
1233 | |
|
|
1234 | ev_timer *timer (struct ev_loop *loop, NV after, NV repeat, SV *cb) |
|
|
1235 | ALIAS: |
|
|
1236 | timer_ns = 1 |
|
|
1237 | INIT: |
|
|
1238 | CHECK_REPEAT (repeat); |
|
|
1239 | CODE: |
|
|
1240 | RETVAL = e_new (sizeof (ev_timer), cb, ST (0)); |
|
|
1241 | ev_timer_set (RETVAL, after, repeat); |
|
|
1242 | if (!ix) START (timer, RETVAL); |
|
|
1243 | OUTPUT: |
|
|
1244 | RETVAL |
|
|
1245 | |
|
|
1246 | SV *periodic (struct ev_loop *loop, NV at, NV interval, SV *reschedule_cb, SV *cb) |
|
|
1247 | ALIAS: |
|
|
1248 | periodic_ns = 1 |
|
|
1249 | INIT: |
|
|
1250 | CHECK_REPEAT (interval); |
|
|
1251 | CODE: |
|
|
1252 | { |
|
|
1253 | ev_periodic *w; |
|
|
1254 | w = e_new (sizeof (ev_periodic), cb, ST (0)); |
|
|
1255 | w->fh = SvTRUE (reschedule_cb) ? newSVsv (reschedule_cb) : 0; |
|
|
1256 | ev_periodic_set (w, at, interval, w->fh ? e_periodic_cb : 0); |
|
|
1257 | RETVAL = e_bless ((ev_watcher *)w, stash_periodic); |
|
|
1258 | if (!ix) START (periodic, w); |
|
|
1259 | } |
|
|
1260 | OUTPUT: |
|
|
1261 | RETVAL |
|
|
1262 | |
|
|
1263 | #if 0 |
|
|
1264 | |
|
|
1265 | ev_signal *signal (struct ev_loop *loop, SV *signal, SV *cb) |
|
|
1266 | ALIAS: |
|
|
1267 | signal_ns = 1 |
|
|
1268 | CODE: |
|
|
1269 | { |
|
|
1270 | Signal signum = sv_signum (signal); |
|
|
1271 | CHECK_SIG (signal, signum); |
|
|
1272 | |
|
|
1273 | RETVAL = e_new (sizeof (ev_signal), cb, ST (0)); |
|
|
1274 | ev_signal_set (RETVAL, signum); |
|
|
1275 | if (!ix) START (signal, RETVAL); |
|
|
1276 | } |
|
|
1277 | OUTPUT: |
|
|
1278 | RETVAL |
|
|
1279 | |
|
|
1280 | #endif |
|
|
1281 | |
|
|
1282 | ev_idle *idle (struct ev_loop *loop, SV *cb) |
|
|
1283 | ALIAS: |
|
|
1284 | idle_ns = 1 |
|
|
1285 | CODE: |
|
|
1286 | RETVAL = e_new (sizeof (ev_idle), cb, ST (0)); |
|
|
1287 | ev_idle_set (RETVAL); |
|
|
1288 | if (!ix) START (idle, RETVAL); |
|
|
1289 | OUTPUT: |
|
|
1290 | RETVAL |
|
|
1291 | |
|
|
1292 | ev_prepare *prepare (struct ev_loop *loop, SV *cb) |
|
|
1293 | ALIAS: |
|
|
1294 | prepare_ns = 1 |
|
|
1295 | CODE: |
|
|
1296 | RETVAL = e_new (sizeof (ev_prepare), cb, ST (0)); |
|
|
1297 | ev_prepare_set (RETVAL); |
|
|
1298 | if (!ix) START (prepare, RETVAL); |
|
|
1299 | OUTPUT: |
|
|
1300 | RETVAL |
|
|
1301 | |
|
|
1302 | ev_check *check (struct ev_loop *loop, SV *cb) |
|
|
1303 | ALIAS: |
|
|
1304 | check_ns = 1 |
|
|
1305 | CODE: |
|
|
1306 | RETVAL = e_new (sizeof (ev_check), cb, ST (0)); |
|
|
1307 | ev_check_set (RETVAL); |
|
|
1308 | if (!ix) START (check, RETVAL); |
|
|
1309 | OUTPUT: |
|
|
1310 | RETVAL |
|
|
1311 | |
|
|
1312 | ev_fork *fork (struct ev_loop *loop, SV *cb) |
|
|
1313 | ALIAS: |
|
|
1314 | fork_ns = 1 |
|
|
1315 | CODE: |
|
|
1316 | RETVAL = e_new (sizeof (ev_fork), cb, ST (0)); |
|
|
1317 | ev_fork_set (RETVAL); |
|
|
1318 | if (!ix) START (fork, RETVAL); |
|
|
1319 | OUTPUT: |
|
|
1320 | RETVAL |
|
|
1321 | |
|
|
1322 | ev_child *child (struct ev_loop *loop, int pid, int trace, SV *cb) |
|
|
1323 | ALIAS: |
|
|
1324 | child_ns = 1 |
|
|
1325 | CODE: |
|
|
1326 | RETVAL = e_new (sizeof (ev_child), cb, ST (0)); |
|
|
1327 | ev_child_set (RETVAL, pid, trace); |
|
|
1328 | if (!ix) START (child, RETVAL); |
|
|
1329 | OUTPUT: |
|
|
1330 | RETVAL |
|
|
1331 | |
|
|
1332 | ev_stat *stat (struct ev_loop *loop, SV *path, NV interval, SV *cb) |
|
|
1333 | ALIAS: |
|
|
1334 | stat_ns = 1 |
|
|
1335 | CODE: |
|
|
1336 | RETVAL = e_new (sizeof (ev_stat), cb, ST (0)); |
|
|
1337 | RETVAL->fh = newSVsv (path); |
|
|
1338 | ev_stat_set (RETVAL, SvPVbyte_nolen (RETVAL->fh), interval); |
|
|
1339 | if (!ix) START (stat, RETVAL); |
|
|
1340 | OUTPUT: |
|
|
1341 | RETVAL |
|
|
1342 | |
|
|
1343 | ev_embed *embed (struct ev_loop *loop, struct ev_loop *other, SV *cb = &PL_sv_undef) |
|
|
1344 | ALIAS: |
|
|
1345 | embed_ns = 1 |
|
|
1346 | CODE: |
|
|
1347 | { |
|
|
1348 | if (!(ev_backend (other) & ev_embeddable_backends ())) |
|
|
1349 | croak ("passed loop is not embeddable via EV::embed,"); |
|
|
1350 | |
|
|
1351 | RETVAL = e_new (sizeof (ev_embed), cb, ST (0)); |
|
|
1352 | RETVAL->fh = newSVsv (ST (1)); |
|
|
1353 | ev_embed_set (RETVAL, other); |
|
|
1354 | |
|
|
1355 | if (!SvOK (cb)) ev_set_cb (RETVAL, 0); |
|
|
1356 | |
|
|
1357 | if (!ix) START (embed, RETVAL); |
|
|
1358 | } |
|
|
1359 | OUTPUT: |
|
|
1360 | RETVAL |
|
|
1361 | |
|
|
1362 | ev_async *async (struct ev_loop *loop, SV *cb) |
|
|
1363 | ALIAS: |
|
|
1364 | async_ns = 1 |
|
|
1365 | CODE: |
|
|
1366 | RETVAL = e_new (sizeof (ev_async), cb, ST (0)); |
|
|
1367 | ev_async_set (RETVAL); |
|
|
1368 | if (!ix) START (async, RETVAL); |
|
|
1369 | OUTPUT: |
|
|
1370 | RETVAL |
|
|
1371 | |
|
|
1372 | void once (struct ev_loop *loop, SV *fh, int events, SV *timeout, SV *cb) |
|
|
1373 | CODE: |
|
|
1374 | ev_once ( |
|
|
1375 | loop, |
|
|
1376 | sv_fileno (fh), events, |
|
|
1377 | SvOK (timeout) ? SvNV (timeout) : -1., |
|
|
1378 | e_once_cb, |
|
|
1379 | newSVsv (cb) |
|
|
1380 | ); |
|
|
1381 | |