… | |
… | |
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); \ |
… | |
… | |
137 | |
138 | |
138 | w = (ev_watcher *)SvPVX (self); |
139 | w = (ev_watcher *)SvPVX (self); |
139 | |
140 | |
140 | ev_init (w, e_cb); |
141 | ev_init (w, e_cb); |
141 | |
142 | |
142 | w->loop = SvREFCNT_inc (SvRV (loop)); |
143 | w->loop = SvREFCNT_inc (SvRV (loop)); |
143 | w->flags = WFLAG_KEEPALIVE; |
144 | w->e_flags = WFLAG_KEEPALIVE; |
144 | w->data = 0; |
145 | w->data = 0; |
145 | w->fh = 0; |
146 | w->fh = 0; |
146 | w->cb_sv = SvTEMP (cb_sv) && SvREFCNT (cb_sv) == 1 ? SvREFCNT_inc (cb_sv) : newSVsv (cb_sv); |
147 | w->cb_sv = SvTEMP (cb_sv) && SvREFCNT (cb_sv) == 1 ? SvREFCNT_inc (cb_sv) : newSVsv (cb_sv); |
147 | w->self = self; |
148 | w->self = self; |
148 | |
149 | |
149 | return (void *)w; |
150 | return (void *)w; |
150 | } |
151 | } |
151 | |
152 | |
152 | static void |
153 | static void |
… | |
… | |
388 | evapi.sv_signum = sv_signum; |
389 | evapi.sv_signum = sv_signum; |
389 | evapi.supported_backends = ev_supported_backends (); |
390 | evapi.supported_backends = ev_supported_backends (); |
390 | evapi.recommended_backends = ev_recommended_backends (); |
391 | evapi.recommended_backends = ev_recommended_backends (); |
391 | evapi.embeddable_backends = ev_embeddable_backends (); |
392 | evapi.embeddable_backends = ev_embeddable_backends (); |
392 | evapi.time = ev_time; |
393 | evapi.time = ev_time; |
|
|
394 | evapi.sleep = ev_sleep; |
393 | evapi.loop_new = ev_loop_new; |
395 | evapi.loop_new = ev_loop_new; |
394 | evapi.loop_destroy = ev_loop_destroy; |
396 | evapi.loop_destroy = ev_loop_destroy; |
395 | evapi.loop_fork = ev_loop_fork; |
397 | evapi.loop_fork = ev_loop_fork; |
396 | evapi.loop_count = ev_loop_count; |
398 | evapi.loop_count = ev_loop_count; |
397 | evapi.now = ev_now; |
399 | evapi.now = ev_now; |
… | |
… | |
424 | evapi.embed_start = ev_embed_start; |
426 | evapi.embed_start = ev_embed_start; |
425 | evapi.embed_stop = ev_embed_stop; |
427 | evapi.embed_stop = ev_embed_stop; |
426 | evapi.embed_sweep = ev_embed_sweep; |
428 | evapi.embed_sweep = ev_embed_sweep; |
427 | evapi.fork_start = ev_fork_start; |
429 | evapi.fork_start = ev_fork_start; |
428 | evapi.fork_stop = ev_fork_stop; |
430 | evapi.fork_stop = ev_fork_stop; |
|
|
431 | evapi.async_start = ev_async_start; |
|
|
432 | evapi.async_stop = ev_async_stop; |
|
|
433 | evapi.async_send = ev_async_send; |
429 | evapi.clear_pending = ev_clear_pending; |
434 | evapi.clear_pending = ev_clear_pending; |
430 | evapi.invoke = ev_invoke; |
435 | evapi.invoke = ev_invoke; |
431 | |
436 | |
432 | sv_setiv (sv, (IV)&evapi); |
437 | sv_setiv (sv, (IV)&evapi); |
433 | SvREADONLY_on (sv); |
438 | SvREADONLY_on (sv); |
… | |
… | |
453 | RETVAL = newSVsv (default_loop_sv); |
458 | RETVAL = newSVsv (default_loop_sv); |
454 | } |
459 | } |
455 | OUTPUT: |
460 | OUTPUT: |
456 | RETVAL |
461 | RETVAL |
457 | |
462 | |
|
|
463 | void ev_default_destroy () |
|
|
464 | CODE: |
|
|
465 | ev_default_destroy (); |
|
|
466 | SvREFCNT_dec (default_loop_sv); |
|
|
467 | default_loop_sv = 0; |
|
|
468 | |
|
|
469 | unsigned int ev_supported_backends () |
|
|
470 | |
|
|
471 | unsigned int ev_recommended_backends () |
|
|
472 | |
|
|
473 | unsigned int ev_embeddable_backends () |
|
|
474 | |
458 | NV ev_time () |
475 | NV ev_time () |
459 | |
476 | |
460 | NV ev_now () |
477 | NV ev_now () |
461 | C_ARGS: evapi.default_loop |
478 | C_ARGS: evapi.default_loop |
462 | |
479 | |
… | |
… | |
464 | C_ARGS: evapi.default_loop |
481 | C_ARGS: evapi.default_loop |
465 | |
482 | |
466 | unsigned int ev_loop_count () |
483 | unsigned int ev_loop_count () |
467 | C_ARGS: evapi.default_loop |
484 | C_ARGS: evapi.default_loop |
468 | |
485 | |
|
|
486 | void ev_set_io_collect_interval (NV interval) |
|
|
487 | C_ARGS: evapi.default_loop, interval |
|
|
488 | |
|
|
489 | void ev_set_timeout_collect_interval (NV interval) |
|
|
490 | C_ARGS: evapi.default_loop, interval |
|
|
491 | |
469 | void ev_loop (int flags = 0) |
492 | void ev_loop (int flags = 0) |
470 | C_ARGS: evapi.default_loop, flags |
493 | C_ARGS: evapi.default_loop, flags |
471 | |
494 | |
472 | void ev_unloop (int how = 1) |
495 | void ev_unloop (int how = EVUNLOOP_ONE) |
473 | C_ARGS: evapi.default_loop, how |
496 | C_ARGS: evapi.default_loop, how |
474 | |
497 | |
475 | void ev_feed_fd_event (int fd, int revents = EV_NONE) |
498 | void ev_feed_fd_event (int fd, int revents = EV_NONE) |
476 | C_ARGS: evapi.default_loop, fd, revents |
499 | C_ARGS: evapi.default_loop, fd, revents |
477 | |
500 | |
… | |
… | |
582 | ev_fork_set (RETVAL); |
605 | ev_fork_set (RETVAL); |
583 | if (!ix) START (fork, RETVAL); |
606 | if (!ix) START (fork, RETVAL); |
584 | OUTPUT: |
607 | OUTPUT: |
585 | RETVAL |
608 | RETVAL |
586 | |
609 | |
587 | ev_child *child (int pid, SV *cb) |
610 | ev_child *child (int pid, int trace, SV *cb) |
588 | ALIAS: |
611 | ALIAS: |
589 | child_ns = 1 |
612 | child_ns = 1 |
590 | CODE: |
613 | CODE: |
591 | RETVAL = e_new (sizeof (ev_child), cb, default_loop_sv); |
614 | RETVAL = e_new (sizeof (ev_child), cb, default_loop_sv); |
592 | ev_child_set (RETVAL, pid); |
615 | ev_child_set (RETVAL, pid, trace); |
593 | if (!ix) START (child, RETVAL); |
616 | if (!ix) START (child, RETVAL); |
594 | OUTPUT: |
617 | OUTPUT: |
595 | RETVAL |
618 | RETVAL |
596 | |
619 | |
597 | ev_stat *stat (SV *path, NV interval, SV *cb) |
620 | ev_stat *stat (SV *path, NV interval, SV *cb) |
… | |
… | |
652 | C_ARGS: e_loop (w), w, revents |
675 | C_ARGS: e_loop (w), w, revents |
653 | |
676 | |
654 | int keepalive (ev_watcher *w, int new_value = 0) |
677 | int keepalive (ev_watcher *w, int new_value = 0) |
655 | CODE: |
678 | CODE: |
656 | { |
679 | { |
657 | RETVAL = w->flags & WFLAG_KEEPALIVE; |
680 | RETVAL = w->e_flags & WFLAG_KEEPALIVE; |
658 | new_value = new_value ? WFLAG_KEEPALIVE : 0; |
681 | new_value = new_value ? WFLAG_KEEPALIVE : 0; |
659 | |
682 | |
660 | if (items > 1 && ((new_value ^ w->flags) & WFLAG_KEEPALIVE)) |
683 | if (items > 1 && ((new_value ^ w->e_flags) & WFLAG_KEEPALIVE)) |
661 | { |
684 | { |
662 | REF (w); |
685 | REF (w); |
663 | w->flags = (w->flags & ~WFLAG_KEEPALIVE) | new_value; |
686 | w->e_flags = (w->e_flags & ~WFLAG_KEEPALIVE) | new_value; |
664 | UNREF (w); |
687 | UNREF (w); |
665 | } |
688 | } |
666 | } |
689 | } |
667 | OUTPUT: |
690 | OUTPUT: |
668 | RETVAL |
691 | RETVAL |
… | |
… | |
687 | { |
710 | { |
688 | SvREFCNT_dec (w->data); |
711 | SvREFCNT_dec (w->data); |
689 | w->data = newSVsv (new_data); |
712 | w->data = newSVsv (new_data); |
690 | } |
713 | } |
691 | } |
714 | } |
|
|
715 | OUTPUT: |
|
|
716 | RETVAL |
|
|
717 | |
|
|
718 | SV *loop (ev_watcher *w) |
|
|
719 | CODE: |
|
|
720 | RETVAL = newRV_inc (w->loop); |
692 | OUTPUT: |
721 | OUTPUT: |
693 | RETVAL |
722 | RETVAL |
694 | |
723 | |
695 | int priority (ev_watcher *w, int new_priority = 0) |
724 | int priority (ev_watcher *w, int new_priority = 0) |
696 | CODE: |
725 | CODE: |
… | |
… | |
909 | void DESTROY (ev_idle *w) |
938 | void DESTROY (ev_idle *w) |
910 | CODE: |
939 | CODE: |
911 | STOP (idle, w); |
940 | STOP (idle, w); |
912 | e_destroy (w); |
941 | e_destroy (w); |
913 | |
942 | |
914 | MODULE = EV PACKAGE = EV::Prepare PREFIX = ev_check_ |
943 | MODULE = EV PACKAGE = EV::Prepare PREFIX = ev_prepare_ |
915 | |
944 | |
916 | void ev_prepare_start (ev_prepare *w) |
945 | void ev_prepare_start (ev_prepare *w) |
917 | CODE: |
946 | CODE: |
918 | START (prepare, w); |
947 | START (prepare, w); |
919 | |
948 | |
… | |
… | |
969 | void DESTROY (ev_child *w) |
998 | void DESTROY (ev_child *w) |
970 | CODE: |
999 | CODE: |
971 | STOP (child, w); |
1000 | STOP (child, w); |
972 | e_destroy (w); |
1001 | e_destroy (w); |
973 | |
1002 | |
974 | void set (ev_child *w, int pid) |
1003 | void set (ev_child *w, int pid, int trace) |
975 | CODE: |
1004 | CODE: |
976 | RESET (child, w, (w, pid)); |
1005 | RESET (child, w, (w, pid, trace)); |
977 | |
1006 | |
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) |
1007 | int pid (ev_child *w) |
991 | ALIAS: |
1008 | ALIAS: |
992 | rpid = 1 |
1009 | rpid = 1 |
|
|
1010 | rstatus = 2 |
993 | CODE: |
1011 | CODE: |
994 | RETVAL = ix ? w->rpid : w->rstatus; |
1012 | RETVAL = ix == 0 ? w->pid |
|
|
1013 | : ix == 1 ? w->rpid |
|
|
1014 | : w->rstatus; |
995 | OUTPUT: |
1015 | OUTPUT: |
996 | RETVAL |
1016 | RETVAL |
997 | |
1017 | |
998 | MODULE = EV PACKAGE = EV::Stat PREFIX = ev_stat_ |
1018 | MODULE = EV PACKAGE = EV::Stat PREFIX = ev_stat_ |
999 | |
1019 | |
… | |
… | |
1115 | CODE: |
1135 | CODE: |
1116 | RETVAL = newSVsv (w->fh); |
1136 | RETVAL = newSVsv (w->fh); |
1117 | OUTPUT: |
1137 | OUTPUT: |
1118 | RETVAL |
1138 | RETVAL |
1119 | |
1139 | |
1120 | MODULE = EV PACKAGE = EV::Loop PREFIX = ev_loop_ |
1140 | MODULE = EV PACKAGE = EV::Loop PREFIX = ev_ |
1121 | |
1141 | |
1122 | SV *new (SV *klass, unsigned int flags = 0) |
1142 | SV *new (SV *klass, unsigned int flags = 0) |
1123 | CODE: |
1143 | CODE: |
1124 | { |
1144 | { |
1125 | struct ev_loop *loop = ev_loop_new (flags); |
1145 | struct ev_loop *loop = ev_loop_new (flags); |
… | |
… | |
1134 | |
1154 | |
1135 | void DESTROY (struct ev_loop *loop) |
1155 | void DESTROY (struct ev_loop *loop) |
1136 | CODE: |
1156 | CODE: |
1137 | if (loop != evapi.default_loop) /* global destruction sucks */ |
1157 | if (loop != evapi.default_loop) /* global destruction sucks */ |
1138 | ev_loop_destroy (loop); |
1158 | ev_loop_destroy (loop); |
|
|
1159 | |
|
|
1160 | void ev_loop_fork (struct ev_loop *loop) |
|
|
1161 | |
|
|
1162 | NV ev_now (struct ev_loop *loop) |
|
|
1163 | |
|
|
1164 | void ev_set_io_collect_interval (struct ev_loop *loop, NV interval) |
|
|
1165 | |
|
|
1166 | void ev_set_timeout_collect_interval (struct ev_loop *loop, NV interval) |
|
|
1167 | |
|
|
1168 | unsigned int ev_backend (struct ev_loop *loop) |
|
|
1169 | |
|
|
1170 | unsigned int ev_loop_count (struct ev_loop *loop) |
|
|
1171 | |
|
|
1172 | void ev_loop (struct ev_loop *loop, int flags = 0) |
|
|
1173 | |
|
|
1174 | void ev_unloop (struct ev_loop *loop, int how = 1) |
|
|
1175 | |
|
|
1176 | void ev_feed_fd_event (struct ev_loop *loop, int fd, int revents = EV_NONE) |
|
|
1177 | |
|
|
1178 | #if 0 |
|
|
1179 | |
|
|
1180 | void ev_feed_signal_event (struct ev_loop *loop, SV *signal) |
|
|
1181 | CODE: |
|
|
1182 | { |
|
|
1183 | Signal signum = sv_signum (signal); |
|
|
1184 | CHECK_SIG (signal, signum); |
|
|
1185 | |
|
|
1186 | ev_feed_signal_event (loop, signum); |
|
|
1187 | } |
|
|
1188 | |
|
|
1189 | #endif |
1139 | |
1190 | |
1140 | ev_io *io (struct ev_loop *loop, SV *fh, int events, SV *cb) |
1191 | ev_io *io (struct ev_loop *loop, SV *fh, int events, SV *cb) |
1141 | ALIAS: |
1192 | ALIAS: |
1142 | io_ns = 1 |
1193 | io_ns = 1 |
1143 | CODE: |
1194 | CODE: |
… | |
… | |
1151 | if (!ix) START (io, RETVAL); |
1202 | if (!ix) START (io, RETVAL); |
1152 | } |
1203 | } |
1153 | OUTPUT: |
1204 | OUTPUT: |
1154 | RETVAL |
1205 | RETVAL |
1155 | |
1206 | |
|
|
1207 | ev_timer *timer (struct ev_loop *loop, NV after, NV repeat, SV *cb) |
|
|
1208 | ALIAS: |
|
|
1209 | timer_ns = 1 |
|
|
1210 | INIT: |
|
|
1211 | CHECK_REPEAT (repeat); |
|
|
1212 | CODE: |
|
|
1213 | RETVAL = e_new (sizeof (ev_timer), cb, ST (0)); |
|
|
1214 | ev_timer_set (RETVAL, after, repeat); |
|
|
1215 | if (!ix) START (timer, RETVAL); |
|
|
1216 | OUTPUT: |
|
|
1217 | RETVAL |
|
|
1218 | |
|
|
1219 | SV *periodic (struct ev_loop *loop, NV at, NV interval, SV *reschedule_cb, SV *cb) |
|
|
1220 | ALIAS: |
|
|
1221 | periodic_ns = 1 |
|
|
1222 | INIT: |
|
|
1223 | CHECK_REPEAT (interval); |
|
|
1224 | CODE: |
|
|
1225 | { |
|
|
1226 | ev_periodic *w; |
|
|
1227 | w = e_new (sizeof (ev_periodic), cb, ST (0)); |
|
|
1228 | w->fh = SvTRUE (reschedule_cb) ? newSVsv (reschedule_cb) : 0; |
|
|
1229 | ev_periodic_set (w, at, interval, w->fh ? e_periodic_cb : 0); |
|
|
1230 | RETVAL = e_bless ((ev_watcher *)w, stash_periodic); |
|
|
1231 | if (!ix) START (periodic, w); |
|
|
1232 | } |
|
|
1233 | OUTPUT: |
|
|
1234 | RETVAL |
|
|
1235 | |
|
|
1236 | #if 0 |
|
|
1237 | |
|
|
1238 | ev_signal *signal (struct ev_loop *loop, SV *signal, SV *cb) |
|
|
1239 | ALIAS: |
|
|
1240 | signal_ns = 1 |
|
|
1241 | CODE: |
|
|
1242 | { |
|
|
1243 | Signal signum = sv_signum (signal); |
|
|
1244 | CHECK_SIG (signal, signum); |
|
|
1245 | |
|
|
1246 | RETVAL = e_new (sizeof (ev_signal), cb, ST (0)); |
|
|
1247 | ev_signal_set (RETVAL, signum); |
|
|
1248 | if (!ix) START (signal, RETVAL); |
|
|
1249 | } |
|
|
1250 | OUTPUT: |
|
|
1251 | RETVAL |
|
|
1252 | |
|
|
1253 | #endif |
|
|
1254 | |
|
|
1255 | ev_idle *idle (struct ev_loop *loop, SV *cb) |
|
|
1256 | ALIAS: |
|
|
1257 | idle_ns = 1 |
|
|
1258 | CODE: |
|
|
1259 | RETVAL = e_new (sizeof (ev_idle), cb, ST (0)); |
|
|
1260 | ev_idle_set (RETVAL); |
|
|
1261 | if (!ix) START (idle, RETVAL); |
|
|
1262 | OUTPUT: |
|
|
1263 | RETVAL |
|
|
1264 | |
|
|
1265 | ev_prepare *prepare (struct ev_loop *loop, SV *cb) |
|
|
1266 | ALIAS: |
|
|
1267 | prepare_ns = 1 |
|
|
1268 | CODE: |
|
|
1269 | RETVAL = e_new (sizeof (ev_prepare), cb, ST (0)); |
|
|
1270 | ev_prepare_set (RETVAL); |
|
|
1271 | if (!ix) START (prepare, RETVAL); |
|
|
1272 | OUTPUT: |
|
|
1273 | RETVAL |
|
|
1274 | |
|
|
1275 | ev_check *check (struct ev_loop *loop, SV *cb) |
|
|
1276 | ALIAS: |
|
|
1277 | check_ns = 1 |
|
|
1278 | CODE: |
|
|
1279 | RETVAL = e_new (sizeof (ev_check), cb, ST (0)); |
|
|
1280 | ev_check_set (RETVAL); |
|
|
1281 | if (!ix) START (check, RETVAL); |
|
|
1282 | OUTPUT: |
|
|
1283 | RETVAL |
|
|
1284 | |
|
|
1285 | ev_fork *fork (struct ev_loop *loop, SV *cb) |
|
|
1286 | ALIAS: |
|
|
1287 | fork_ns = 1 |
|
|
1288 | CODE: |
|
|
1289 | RETVAL = e_new (sizeof (ev_fork), cb, ST (0)); |
|
|
1290 | ev_fork_set (RETVAL); |
|
|
1291 | if (!ix) START (fork, RETVAL); |
|
|
1292 | OUTPUT: |
|
|
1293 | RETVAL |
|
|
1294 | |
|
|
1295 | ev_child *child (struct ev_loop *loop, int pid, int trace, SV *cb) |
|
|
1296 | ALIAS: |
|
|
1297 | child_ns = 1 |
|
|
1298 | CODE: |
|
|
1299 | RETVAL = e_new (sizeof (ev_child), cb, ST (0)); |
|
|
1300 | ev_child_set (RETVAL, pid, trace); |
|
|
1301 | if (!ix) START (child, RETVAL); |
|
|
1302 | OUTPUT: |
|
|
1303 | RETVAL |
|
|
1304 | |
|
|
1305 | ev_stat *stat (struct ev_loop *loop, SV *path, NV interval, SV *cb) |
|
|
1306 | ALIAS: |
|
|
1307 | stat_ns = 1 |
|
|
1308 | CODE: |
|
|
1309 | RETVAL = e_new (sizeof (ev_stat), cb, ST (0)); |
|
|
1310 | RETVAL->fh = newSVsv (path); |
|
|
1311 | ev_stat_set (RETVAL, SvPVbyte_nolen (RETVAL->fh), interval); |
|
|
1312 | if (!ix) START (stat, RETVAL); |
|
|
1313 | OUTPUT: |
|
|
1314 | RETVAL |
|
|
1315 | |
|
|
1316 | ev_embed *embed (struct ev_loop *loop, struct ev_loop *other, SV *cb = &PL_sv_undef) |
|
|
1317 | ALIAS: |
|
|
1318 | embed_ns = 1 |
|
|
1319 | CODE: |
|
|
1320 | { |
|
|
1321 | if (!(ev_backend (other) & ev_embeddable_backends ())) |
|
|
1322 | croak ("passed loop is not embeddable via EV::embed,"); |
|
|
1323 | |
|
|
1324 | RETVAL = e_new (sizeof (ev_embed), cb, ST (0)); |
|
|
1325 | RETVAL->fh = newSVsv (ST (1)); |
|
|
1326 | ev_embed_set (RETVAL, other); |
|
|
1327 | |
|
|
1328 | if (!SvOK (cb)) ev_set_cb (RETVAL, 0); |
|
|
1329 | |
|
|
1330 | if (!ix) START (embed, RETVAL); |
|
|
1331 | } |
|
|
1332 | OUTPUT: |
|
|
1333 | RETVAL |
|
|
1334 | |
|
|
1335 | void once (struct ev_loop *loop, SV *fh, int events, SV *timeout, SV *cb) |
|
|
1336 | CODE: |
|
|
1337 | ev_once ( |
|
|
1338 | loop, |
|
|
1339 | sv_fileno (fh), events, |
|
|
1340 | SvOK (timeout) ? SvNV (timeout) : -1., |
|
|
1341 | e_once_cb, |
|
|
1342 | newSVsv (cb) |
|
|
1343 | ); |
|
|
1344 | |