ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/EV/EV.xs
(Generate patch)

Comparing EV/EV.xs (file contents):
Revision 1.96 by root, Thu Dec 20 10:12:22 2007 UTC vs.
Revision 1.111 by root, Sun May 18 10:45:36 2008 UTC

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 EV_PROTOTYPES 1
8#define EV_H <ev.h>
9#include "EV/EVAPI.h"
10
11/* fix perl api breakage */ 7/* fix perl api breakage */
12#undef signal 8#undef signal
13#undef sigaction 9#undef sigaction
10
11#define EV_PROTOTYPES 1
12#define EV_USE_NANOSLEEP EV_USE_MONOTONIC
13#define EV_H <ev.h>
14#include "EV/EVAPI.h"
14 15
15#define EV_SELECT_IS_WINSOCKET 0 16#define EV_SELECT_IS_WINSOCKET 0
16#ifdef _WIN32 17#ifdef _WIN32
17# define EV_SELECT_USE_FD_SET 0 18# define EV_SELECT_USE_FD_SET 0
18# define NFDBITS PERL_NFDBITS 19# define NFDBITS PERL_NFDBITS
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 */
85static char sig_size [] = { SIG_NUM }; 87static 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
152static void 154static 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
387 evapi.sv_fileno = sv_fileno; 390 evapi.sv_fileno = sv_fileno;
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
440SV *ev_default_loop (unsigned int flags = ev_supported_backends ()) 447SV *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
465void ev_default_destroy ()
466 CODE:
467 ev_default_destroy ();
468 SvREFCNT_dec (default_loop_sv);
469 default_loop_sv = 0;
470
471unsigned int ev_supported_backends ()
472
473unsigned int ev_recommended_backends ()
474
475unsigned int ev_embeddable_backends ()
476
458NV ev_time () 477NV ev_time ()
459 478
460NV ev_now () 479NV 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
466unsigned int ev_loop_count () 485unsigned int ev_loop_count ()
467 C_ARGS: evapi.default_loop 486 C_ARGS: evapi.default_loop
468 487
488void ev_set_io_collect_interval (NV interval)
489 C_ARGS: evapi.default_loop, interval
490
491void ev_set_timeout_collect_interval (NV interval)
492 C_ARGS: evapi.default_loop, interval
493
469void ev_loop (int flags = 0) 494void ev_loop (int flags = 0)
470 C_ARGS: evapi.default_loop, flags 495 C_ARGS: evapi.default_loop, flags
471 496
472void ev_unloop (int how = 1) 497void ev_unloop (int how = EVUNLOOP_ONE)
473 C_ARGS: evapi.default_loop, how 498 C_ARGS: evapi.default_loop, how
474 499
475void ev_feed_fd_event (int fd, int revents = EV_NONE) 500void 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
587ev_child *child (int pid, SV *cb) 612ev_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
597ev_stat *stat (SV *path, NV interval, SV *cb) 622ev_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
652ev_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
627void once (SV *fh, int events, SV *timeout, SV *cb) 662void 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
654int keepalive (ev_watcher *w, int new_value = 0) 689int 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
730SV *loop (ev_watcher *w)
731 CODE:
732 RETVAL = newRV_inc (w->loop);
692 OUTPUT: 733 OUTPUT:
693 RETVAL 734 RETVAL
694 735
695int priority (ev_watcher *w, int new_priority = 0) 736int priority (ev_watcher *w, int new_priority = 0)
696 CODE: 737 CODE:
848 INIT: 889 INIT:
849 CHECK_REPEAT (repeat); 890 CHECK_REPEAT (repeat);
850 CODE: 891 CODE:
851 RESET (timer, w, (w, after, repeat)); 892 RESET (timer, w, (w, after, repeat));
852 893
853NV at (ev_timer *w)
854 CODE:
855 RETVAL = w->at;
856 OUTPUT:
857 RETVAL
858
859MODULE = EV PACKAGE = EV::Periodic PREFIX = ev_periodic_ 894MODULE = EV PACKAGE = EV::Periodic PREFIX = ev_periodic_
860 895
861void ev_periodic_start (ev_periodic *w) 896void ev_periodic_start (ev_periodic *w)
862 INIT: 897 INIT:
863 CHECK_REPEAT (w->interval); 898 CHECK_REPEAT (w->interval);
890 RESET (periodic, w, (w, at, interval, w->fh ? e_periodic_cb : 0)); 925 RESET (periodic, w, (w, at, interval, w->fh ? e_periodic_cb : 0));
891} 926}
892 927
893NV at (ev_periodic *w) 928NV at (ev_periodic *w)
894 CODE: 929 CODE:
895 RETVAL = w->at; 930 RETVAL = ev_periodic_at (w);
896 OUTPUT: 931 OUTPUT:
897 RETVAL 932 RETVAL
898 933
899MODULE = EV PACKAGE = EV::Idle PREFIX = ev_idle_ 934MODULE = EV PACKAGE = EV::Idle PREFIX = ev_idle_
900 935
909void DESTROY (ev_idle *w) 944void DESTROY (ev_idle *w)
910 CODE: 945 CODE:
911 STOP (idle, w); 946 STOP (idle, w);
912 e_destroy (w); 947 e_destroy (w);
913 948
914MODULE = EV PACKAGE = EV::Prepare PREFIX = ev_check_ 949MODULE = EV PACKAGE = EV::Prepare PREFIX = ev_prepare_
915 950
916void ev_prepare_start (ev_prepare *w) 951void ev_prepare_start (ev_prepare *w)
917 CODE: 952 CODE:
918 START (prepare, w); 953 START (prepare, w);
919 954
969void DESTROY (ev_child *w) 1004void DESTROY (ev_child *w)
970 CODE: 1005 CODE:
971 STOP (child, w); 1006 STOP (child, w);
972 e_destroy (w); 1007 e_destroy (w);
973 1008
974void set (ev_child *w, int pid) 1009void set (ev_child *w, int pid, int trace)
975 CODE: 1010 CODE:
976 RESET (child, w, (w, pid)); 1011 RESET (child, w, (w, pid, trace));
977 1012
978int 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
990int rstatus (ev_child *w) 1013int pid (ev_child *w)
991 ALIAS: 1014 ALIAS:
992 rpid = 1 1015 rpid = 1
1016 rstatus = 2
993 CODE: 1017 CODE:
994 RETVAL = ix ? w->rpid : w->rstatus; 1018 RETVAL = ix == 0 ? w->pid
1019 : ix == 1 ? w->rpid
1020 : w->rstatus;
995 OUTPUT: 1021 OUTPUT:
996 RETVAL 1022 RETVAL
997 1023
998MODULE = EV PACKAGE = EV::Stat PREFIX = ev_stat_ 1024MODULE = EV PACKAGE = EV::Stat PREFIX = ev_stat_
999 1025
1115 CODE: 1141 CODE:
1116 RETVAL = newSVsv (w->fh); 1142 RETVAL = newSVsv (w->fh);
1117 OUTPUT: 1143 OUTPUT:
1118 RETVAL 1144 RETVAL
1119 1145
1146void ev_embed_sweep (ev_embed *w)
1147 C_ARGS: e_loop (w), w
1148
1149MODULE = EV PACKAGE = EV::Async PREFIX = ev_async_
1150
1151void ev_async_start (ev_async *w)
1152 CODE:
1153 START (async, w);
1154
1155void ev_async_stop (ev_async *w)
1156 CODE:
1157 STOP (async, w);
1158
1159void DESTROY (ev_async *w)
1160 CODE:
1161 STOP (async, w);
1162 e_destroy (w);
1163
1164void ev_async_send (ev_async *w)
1165 C_ARGS: e_loop (w), w
1166
1167SV *ev_async_async_pending (ev_async *w)
1168 CODE:
1169 RETVAL = boolSV (ev_async_pending (w));
1170 OUTPUT:
1171 RETVAL
1172
1120MODULE = EV PACKAGE = EV::Loop PREFIX = ev_loop_ 1173MODULE = EV PACKAGE = EV::Loop PREFIX = ev_
1121 1174
1122SV *new (SV *klass, unsigned int flags = ev_supported_backends ()) 1175SV *new (SV *klass, unsigned int flags = 0)
1123 CODE: 1176 CODE:
1124{ 1177{
1125 struct ev_loop *loop = ev_loop_new (flags); 1178 struct ev_loop *loop = ev_loop_new (flags);
1126 1179
1127 if (!loop) 1180 if (!loop)
1134 1187
1135void DESTROY (struct ev_loop *loop) 1188void DESTROY (struct ev_loop *loop)
1136 CODE: 1189 CODE:
1137 if (loop != evapi.default_loop) /* global destruction sucks */ 1190 if (loop != evapi.default_loop) /* global destruction sucks */
1138 ev_loop_destroy (loop); 1191 ev_loop_destroy (loop);
1192
1193void ev_loop_fork (struct ev_loop *loop)
1194
1195NV ev_now (struct ev_loop *loop)
1196
1197void ev_set_io_collect_interval (struct ev_loop *loop, NV interval)
1198
1199void ev_set_timeout_collect_interval (struct ev_loop *loop, NV interval)
1200
1201unsigned int ev_backend (struct ev_loop *loop)
1202
1203unsigned int ev_loop_count (struct ev_loop *loop)
1204
1205void ev_loop (struct ev_loop *loop, int flags = 0)
1206
1207void ev_unloop (struct ev_loop *loop, int how = 1)
1208
1209void ev_feed_fd_event (struct ev_loop *loop, int fd, int revents = EV_NONE)
1210
1211#if 0
1212
1213void ev_feed_signal_event (struct ev_loop *loop, SV *signal)
1214 CODE:
1215{
1216 Signal signum = sv_signum (signal);
1217 CHECK_SIG (signal, signum);
1218
1219 ev_feed_signal_event (loop, signum);
1220}
1221
1222#endif
1139 1223
1140ev_io *io (struct ev_loop *loop, SV *fh, int events, SV *cb) 1224ev_io *io (struct ev_loop *loop, SV *fh, int events, SV *cb)
1141 ALIAS: 1225 ALIAS:
1142 io_ns = 1 1226 io_ns = 1
1143 CODE: 1227 CODE:
1151 if (!ix) START (io, RETVAL); 1235 if (!ix) START (io, RETVAL);
1152} 1236}
1153 OUTPUT: 1237 OUTPUT:
1154 RETVAL 1238 RETVAL
1155 1239
1240ev_timer *timer (struct ev_loop *loop, NV after, NV repeat, SV *cb)
1241 ALIAS:
1242 timer_ns = 1
1243 INIT:
1244 CHECK_REPEAT (repeat);
1245 CODE:
1246 RETVAL = e_new (sizeof (ev_timer), cb, ST (0));
1247 ev_timer_set (RETVAL, after, repeat);
1248 if (!ix) START (timer, RETVAL);
1249 OUTPUT:
1250 RETVAL
1251
1252SV *periodic (struct ev_loop *loop, NV at, NV interval, SV *reschedule_cb, SV *cb)
1253 ALIAS:
1254 periodic_ns = 1
1255 INIT:
1256 CHECK_REPEAT (interval);
1257 CODE:
1258{
1259 ev_periodic *w;
1260 w = e_new (sizeof (ev_periodic), cb, ST (0));
1261 w->fh = SvTRUE (reschedule_cb) ? newSVsv (reschedule_cb) : 0;
1262 ev_periodic_set (w, at, interval, w->fh ? e_periodic_cb : 0);
1263 RETVAL = e_bless ((ev_watcher *)w, stash_periodic);
1264 if (!ix) START (periodic, w);
1265}
1266 OUTPUT:
1267 RETVAL
1268
1269#if 0
1270
1271ev_signal *signal (struct ev_loop *loop, SV *signal, SV *cb)
1272 ALIAS:
1273 signal_ns = 1
1274 CODE:
1275{
1276 Signal signum = sv_signum (signal);
1277 CHECK_SIG (signal, signum);
1278
1279 RETVAL = e_new (sizeof (ev_signal), cb, ST (0));
1280 ev_signal_set (RETVAL, signum);
1281 if (!ix) START (signal, RETVAL);
1282}
1283 OUTPUT:
1284 RETVAL
1285
1286#endif
1287
1288ev_idle *idle (struct ev_loop *loop, SV *cb)
1289 ALIAS:
1290 idle_ns = 1
1291 CODE:
1292 RETVAL = e_new (sizeof (ev_idle), cb, ST (0));
1293 ev_idle_set (RETVAL);
1294 if (!ix) START (idle, RETVAL);
1295 OUTPUT:
1296 RETVAL
1297
1298ev_prepare *prepare (struct ev_loop *loop, SV *cb)
1299 ALIAS:
1300 prepare_ns = 1
1301 CODE:
1302 RETVAL = e_new (sizeof (ev_prepare), cb, ST (0));
1303 ev_prepare_set (RETVAL);
1304 if (!ix) START (prepare, RETVAL);
1305 OUTPUT:
1306 RETVAL
1307
1308ev_check *check (struct ev_loop *loop, SV *cb)
1309 ALIAS:
1310 check_ns = 1
1311 CODE:
1312 RETVAL = e_new (sizeof (ev_check), cb, ST (0));
1313 ev_check_set (RETVAL);
1314 if (!ix) START (check, RETVAL);
1315 OUTPUT:
1316 RETVAL
1317
1318ev_fork *fork (struct ev_loop *loop, SV *cb)
1319 ALIAS:
1320 fork_ns = 1
1321 CODE:
1322 RETVAL = e_new (sizeof (ev_fork), cb, ST (0));
1323 ev_fork_set (RETVAL);
1324 if (!ix) START (fork, RETVAL);
1325 OUTPUT:
1326 RETVAL
1327
1328ev_child *child (struct ev_loop *loop, int pid, int trace, SV *cb)
1329 ALIAS:
1330 child_ns = 1
1331 CODE:
1332 RETVAL = e_new (sizeof (ev_child), cb, ST (0));
1333 ev_child_set (RETVAL, pid, trace);
1334 if (!ix) START (child, RETVAL);
1335 OUTPUT:
1336 RETVAL
1337
1338ev_stat *stat (struct ev_loop *loop, SV *path, NV interval, SV *cb)
1339 ALIAS:
1340 stat_ns = 1
1341 CODE:
1342 RETVAL = e_new (sizeof (ev_stat), cb, ST (0));
1343 RETVAL->fh = newSVsv (path);
1344 ev_stat_set (RETVAL, SvPVbyte_nolen (RETVAL->fh), interval);
1345 if (!ix) START (stat, RETVAL);
1346 OUTPUT:
1347 RETVAL
1348
1349ev_embed *embed (struct ev_loop *loop, struct ev_loop *other, SV *cb = &PL_sv_undef)
1350 ALIAS:
1351 embed_ns = 1
1352 CODE:
1353{
1354 if (!(ev_backend (other) & ev_embeddable_backends ()))
1355 croak ("passed loop is not embeddable via EV::embed,");
1356
1357 RETVAL = e_new (sizeof (ev_embed), cb, ST (0));
1358 RETVAL->fh = newSVsv (ST (1));
1359 ev_embed_set (RETVAL, other);
1360
1361 if (!SvOK (cb)) ev_set_cb (RETVAL, 0);
1362
1363 if (!ix) START (embed, RETVAL);
1364}
1365 OUTPUT:
1366 RETVAL
1367
1368ev_async *async (struct ev_loop *loop, SV *cb)
1369 ALIAS:
1370 async_ns = 1
1371 CODE:
1372 RETVAL = e_new (sizeof (ev_async), cb, ST (0));
1373 ev_async_set (RETVAL);
1374 if (!ix) START (async, RETVAL);
1375 OUTPUT:
1376 RETVAL
1377
1378void once (struct ev_loop *loop, SV *fh, int events, SV *timeout, SV *cb)
1379 CODE:
1380 ev_once (
1381 loop,
1382 sv_fileno (fh), events,
1383 SvOK (timeout) ? SvNV (timeout) : -1.,
1384 e_once_cb,
1385 newSVsv (cb)
1386 );
1387

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines