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.112 by root, Tue May 20 23:49:41 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)
125 return SvIV (fh); 127 return SvIV (fh);
126 128
127 return -1; 129 return -1;
128} 130}
129 131
132static SV *
133e_get_cv (SV *cb_sv)
134{
135 HV *st;
136 GV *gvp;
137 CV *cv = sv_2cv (cb_sv, &st, &gvp, 0);
138
139 if (!cv)
140 croak ("EV watcher callback must be a CODE reference");
141
142 return (SV *)cv;
143}
144
130static void * 145static void *
131e_new (int size, SV *cb_sv, SV *loop) 146e_new (int size, SV *cb_sv, SV *loop)
132{ 147{
148 SV *cv = e_get_cv (cb_sv);
133 ev_watcher *w; 149 ev_watcher *w;
134 SV *self = NEWSV (0, size); 150 SV *self = NEWSV (0, size);
135 SvPOK_only (self); 151 SvPOK_only (self);
136 SvCUR_set (self, size); 152 SvCUR_set (self, size);
137 153
138 w = (ev_watcher *)SvPVX (self); 154 w = (ev_watcher *)SvPVX (self);
139 155
140 ev_init (w, e_cb); 156 ev_init (w, e_cb);
141 157
142 w->loop = SvREFCNT_inc (SvRV (loop)); 158 w->loop = SvREFCNT_inc (SvRV (loop));
143 w->flags = WFLAG_KEEPALIVE; 159 w->e_flags = WFLAG_KEEPALIVE;
144 w->data = 0; 160 w->data = 0;
145 w->fh = 0; 161 w->fh = 0;
146 w->cb_sv = SvTEMP (cb_sv) && SvREFCNT (cb_sv) == 1 ? SvREFCNT_inc (cb_sv) : newSVsv (cb_sv); 162 w->cb_sv = SvREFCNT_inc (cv);
147 w->self = self; 163 w->self = self;
148 164
149 return (void *)w; 165 return (void *)w;
150} 166}
151 167
152static void 168static void
374 stash_check = gv_stashpv ("EV::Check" , 1); 390 stash_check = gv_stashpv ("EV::Check" , 1);
375 stash_child = gv_stashpv ("EV::Child" , 1); 391 stash_child = gv_stashpv ("EV::Child" , 1);
376 stash_embed = gv_stashpv ("EV::Embed" , 1); 392 stash_embed = gv_stashpv ("EV::Embed" , 1);
377 stash_stat = gv_stashpv ("EV::Stat" , 1); 393 stash_stat = gv_stashpv ("EV::Stat" , 1);
378 stash_fork = gv_stashpv ("EV::Fork" , 1); 394 stash_fork = gv_stashpv ("EV::Fork" , 1);
395 stash_async = gv_stashpv ("EV::Async" , 1);
379 396
380 { 397 {
381 SV *sv = perl_get_sv ("EV::API", TRUE); 398 SV *sv = perl_get_sv ("EV::API", TRUE);
382 perl_get_sv ("EV::API", TRUE); /* silence 5.10 warning */ 399 perl_get_sv ("EV::API", TRUE); /* silence 5.10 warning */
383 400
387 evapi.sv_fileno = sv_fileno; 404 evapi.sv_fileno = sv_fileno;
388 evapi.sv_signum = sv_signum; 405 evapi.sv_signum = sv_signum;
389 evapi.supported_backends = ev_supported_backends (); 406 evapi.supported_backends = ev_supported_backends ();
390 evapi.recommended_backends = ev_recommended_backends (); 407 evapi.recommended_backends = ev_recommended_backends ();
391 evapi.embeddable_backends = ev_embeddable_backends (); 408 evapi.embeddable_backends = ev_embeddable_backends ();
392 evapi.time = ev_time; 409 evapi.time_ = ev_time;
410 evapi.sleep_ = ev_sleep;
393 evapi.loop_new = ev_loop_new; 411 evapi.loop_new = ev_loop_new;
394 evapi.loop_destroy = ev_loop_destroy; 412 evapi.loop_destroy = ev_loop_destroy;
395 evapi.loop_fork = ev_loop_fork; 413 evapi.loop_fork = ev_loop_fork;
396 evapi.loop_count = ev_loop_count; 414 evapi.loop_count = ev_loop_count;
397 evapi.now = ev_now; 415 evapi.now = ev_now;
424 evapi.embed_start = ev_embed_start; 442 evapi.embed_start = ev_embed_start;
425 evapi.embed_stop = ev_embed_stop; 443 evapi.embed_stop = ev_embed_stop;
426 evapi.embed_sweep = ev_embed_sweep; 444 evapi.embed_sweep = ev_embed_sweep;
427 evapi.fork_start = ev_fork_start; 445 evapi.fork_start = ev_fork_start;
428 evapi.fork_stop = ev_fork_stop; 446 evapi.fork_stop = ev_fork_stop;
447 evapi.async_start = ev_async_start;
448 evapi.async_stop = ev_async_stop;
449 evapi.async_send = ev_async_send;
429 evapi.clear_pending = ev_clear_pending; 450 evapi.clear_pending = ev_clear_pending;
430 evapi.invoke = ev_invoke; 451 evapi.invoke = ev_invoke;
431 452
432 sv_setiv (sv, (IV)&evapi); 453 sv_setiv (sv, (IV)&evapi);
433 SvREADONLY_on (sv); 454 SvREADONLY_on (sv);
435#ifndef _WIN32 456#ifndef _WIN32
436 pthread_atfork (0, 0, ev_default_fork); 457 pthread_atfork (0, 0, ev_default_fork);
437#endif 458#endif
438} 459}
439 460
440SV *ev_default_loop (unsigned int flags = ev_supported_backends ()) 461SV *ev_default_loop (unsigned int flags = 0)
441 CODE: 462 CODE:
442{ 463{
443 if (!default_loop_sv) 464 if (!default_loop_sv)
444 { 465 {
445 evapi.default_loop = ev_default_loop (flags); 466 evapi.default_loop = ev_default_loop (flags);
453 RETVAL = newSVsv (default_loop_sv); 474 RETVAL = newSVsv (default_loop_sv);
454} 475}
455 OUTPUT: 476 OUTPUT:
456 RETVAL 477 RETVAL
457 478
479void ev_default_destroy ()
480 CODE:
481 ev_default_destroy ();
482 SvREFCNT_dec (default_loop_sv);
483 default_loop_sv = 0;
484
485unsigned int ev_supported_backends ()
486
487unsigned int ev_recommended_backends ()
488
489unsigned int ev_embeddable_backends ()
490
458NV ev_time () 491NV ev_time ()
459 492
460NV ev_now () 493NV ev_now ()
461 C_ARGS: evapi.default_loop 494 C_ARGS: evapi.default_loop
462 495
464 C_ARGS: evapi.default_loop 497 C_ARGS: evapi.default_loop
465 498
466unsigned int ev_loop_count () 499unsigned int ev_loop_count ()
467 C_ARGS: evapi.default_loop 500 C_ARGS: evapi.default_loop
468 501
502void ev_set_io_collect_interval (NV interval)
503 C_ARGS: evapi.default_loop, interval
504
505void ev_set_timeout_collect_interval (NV interval)
506 C_ARGS: evapi.default_loop, interval
507
469void ev_loop (int flags = 0) 508void ev_loop (int flags = 0)
470 C_ARGS: evapi.default_loop, flags 509 C_ARGS: evapi.default_loop, flags
471 510
472void ev_unloop (int how = 1) 511void ev_unloop (int how = EVUNLOOP_ONE)
473 C_ARGS: evapi.default_loop, how 512 C_ARGS: evapi.default_loop, how
474 513
475void ev_feed_fd_event (int fd, int revents = EV_NONE) 514void ev_feed_fd_event (int fd, int revents = EV_NONE)
476 C_ARGS: evapi.default_loop, fd, revents 515 C_ARGS: evapi.default_loop, fd, revents
477 516
582 ev_fork_set (RETVAL); 621 ev_fork_set (RETVAL);
583 if (!ix) START (fork, RETVAL); 622 if (!ix) START (fork, RETVAL);
584 OUTPUT: 623 OUTPUT:
585 RETVAL 624 RETVAL
586 625
587ev_child *child (int pid, SV *cb) 626ev_child *child (int pid, int trace, SV *cb)
588 ALIAS: 627 ALIAS:
589 child_ns = 1 628 child_ns = 1
590 CODE: 629 CODE:
591 RETVAL = e_new (sizeof (ev_child), cb, default_loop_sv); 630 RETVAL = e_new (sizeof (ev_child), cb, default_loop_sv);
592 ev_child_set (RETVAL, pid); 631 ev_child_set (RETVAL, pid, trace);
593 if (!ix) START (child, RETVAL); 632 if (!ix) START (child, RETVAL);
594 OUTPUT: 633 OUTPUT:
595 RETVAL 634 RETVAL
596 635
597ev_stat *stat (SV *path, NV interval, SV *cb) 636ev_stat *stat (SV *path, NV interval, SV *cb)
619 658
620 if (!SvOK (cb)) ev_set_cb (RETVAL, 0); 659 if (!SvOK (cb)) ev_set_cb (RETVAL, 0);
621 660
622 if (!ix) START (embed, RETVAL); 661 if (!ix) START (embed, RETVAL);
623} 662}
663 OUTPUT:
664 RETVAL
665
666ev_async *async (SV *cb)
667 ALIAS:
668 async_ns = 1
669 CODE:
670 RETVAL = e_new (sizeof (ev_async), cb, default_loop_sv);
671 ev_async_set (RETVAL);
672 if (!ix) START (async, RETVAL);
624 OUTPUT: 673 OUTPUT:
625 RETVAL 674 RETVAL
626 675
627void once (SV *fh, int events, SV *timeout, SV *cb) 676void once (SV *fh, int events, SV *timeout, SV *cb)
628 CODE: 677 CODE:
652 C_ARGS: e_loop (w), w, revents 701 C_ARGS: e_loop (w), w, revents
653 702
654int keepalive (ev_watcher *w, int new_value = 0) 703int keepalive (ev_watcher *w, int new_value = 0)
655 CODE: 704 CODE:
656{ 705{
657 RETVAL = w->flags & WFLAG_KEEPALIVE; 706 RETVAL = w->e_flags & WFLAG_KEEPALIVE;
658 new_value = new_value ? WFLAG_KEEPALIVE : 0; 707 new_value = new_value ? WFLAG_KEEPALIVE : 0;
659 708
660 if (items > 1 && ((new_value ^ w->flags) & WFLAG_KEEPALIVE)) 709 if (items > 1 && ((new_value ^ w->e_flags) & WFLAG_KEEPALIVE))
661 { 710 {
662 REF (w); 711 REF (w);
663 w->flags = (w->flags & ~WFLAG_KEEPALIVE) | new_value; 712 w->e_flags = (w->e_flags & ~WFLAG_KEEPALIVE) | new_value;
664 UNREF (w); 713 UNREF (w);
665 } 714 }
666} 715}
667 OUTPUT: 716 OUTPUT:
668 RETVAL 717 RETVAL
669 718
670SV *cb (ev_watcher *w, SV *new_cb = 0) 719SV *cb (ev_watcher *w, SV *new_cb = 0)
671 CODE: 720 CODE:
672{ 721{
673 RETVAL = newSVsv (w->cb_sv);
674
675 if (items > 1) 722 if (items > 1)
676 sv_setsv (w->cb_sv, new_cb); 723 {
724 new_cb = e_get_cv (new_cb);
725 RETVAL = newRV_noinc (w->cb_sv);
726 w->cb_sv = SvREFCNT_inc (new_cb);
727 }
728 else
729 RETVAL = newRV_inc (w->cb_sv);
677} 730}
678 OUTPUT: 731 OUTPUT:
679 RETVAL 732 RETVAL
680 733
681SV *data (ev_watcher *w, SV *new_data = 0) 734SV *data (ev_watcher *w, SV *new_data = 0)
687 { 740 {
688 SvREFCNT_dec (w->data); 741 SvREFCNT_dec (w->data);
689 w->data = newSVsv (new_data); 742 w->data = newSVsv (new_data);
690 } 743 }
691} 744}
745 OUTPUT:
746 RETVAL
747
748SV *loop (ev_watcher *w)
749 CODE:
750 RETVAL = newRV_inc (w->loop);
692 OUTPUT: 751 OUTPUT:
693 RETVAL 752 RETVAL
694 753
695int priority (ev_watcher *w, int new_priority = 0) 754int priority (ev_watcher *w, int new_priority = 0)
696 CODE: 755 CODE:
848 INIT: 907 INIT:
849 CHECK_REPEAT (repeat); 908 CHECK_REPEAT (repeat);
850 CODE: 909 CODE:
851 RESET (timer, w, (w, after, repeat)); 910 RESET (timer, w, (w, after, repeat));
852 911
853NV at (ev_timer *w)
854 CODE:
855 RETVAL = w->at;
856 OUTPUT:
857 RETVAL
858
859MODULE = EV PACKAGE = EV::Periodic PREFIX = ev_periodic_ 912MODULE = EV PACKAGE = EV::Periodic PREFIX = ev_periodic_
860 913
861void ev_periodic_start (ev_periodic *w) 914void ev_periodic_start (ev_periodic *w)
862 INIT: 915 INIT:
863 CHECK_REPEAT (w->interval); 916 CHECK_REPEAT (w->interval);
890 RESET (periodic, w, (w, at, interval, w->fh ? e_periodic_cb : 0)); 943 RESET (periodic, w, (w, at, interval, w->fh ? e_periodic_cb : 0));
891} 944}
892 945
893NV at (ev_periodic *w) 946NV at (ev_periodic *w)
894 CODE: 947 CODE:
895 RETVAL = w->at; 948 RETVAL = ev_periodic_at (w);
896 OUTPUT: 949 OUTPUT:
897 RETVAL 950 RETVAL
898 951
899MODULE = EV PACKAGE = EV::Idle PREFIX = ev_idle_ 952MODULE = EV PACKAGE = EV::Idle PREFIX = ev_idle_
900 953
909void DESTROY (ev_idle *w) 962void DESTROY (ev_idle *w)
910 CODE: 963 CODE:
911 STOP (idle, w); 964 STOP (idle, w);
912 e_destroy (w); 965 e_destroy (w);
913 966
914MODULE = EV PACKAGE = EV::Prepare PREFIX = ev_check_ 967MODULE = EV PACKAGE = EV::Prepare PREFIX = ev_prepare_
915 968
916void ev_prepare_start (ev_prepare *w) 969void ev_prepare_start (ev_prepare *w)
917 CODE: 970 CODE:
918 START (prepare, w); 971 START (prepare, w);
919 972
969void DESTROY (ev_child *w) 1022void DESTROY (ev_child *w)
970 CODE: 1023 CODE:
971 STOP (child, w); 1024 STOP (child, w);
972 e_destroy (w); 1025 e_destroy (w);
973 1026
974void set (ev_child *w, int pid) 1027void set (ev_child *w, int pid, int trace)
975 CODE: 1028 CODE:
976 RESET (child, w, (w, pid)); 1029 RESET (child, w, (w, pid, trace));
977 1030
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) 1031int pid (ev_child *w)
991 ALIAS: 1032 ALIAS:
992 rpid = 1 1033 rpid = 1
1034 rstatus = 2
993 CODE: 1035 CODE:
994 RETVAL = ix ? w->rpid : w->rstatus; 1036 RETVAL = ix == 0 ? w->pid
1037 : ix == 1 ? w->rpid
1038 : w->rstatus;
995 OUTPUT: 1039 OUTPUT:
996 RETVAL 1040 RETVAL
997 1041
998MODULE = EV PACKAGE = EV::Stat PREFIX = ev_stat_ 1042MODULE = EV PACKAGE = EV::Stat PREFIX = ev_stat_
999 1043
1115 CODE: 1159 CODE:
1116 RETVAL = newSVsv (w->fh); 1160 RETVAL = newSVsv (w->fh);
1117 OUTPUT: 1161 OUTPUT:
1118 RETVAL 1162 RETVAL
1119 1163
1164void ev_embed_sweep (ev_embed *w)
1165 C_ARGS: e_loop (w), w
1166
1167MODULE = EV PACKAGE = EV::Async PREFIX = ev_async_
1168
1169void ev_async_start (ev_async *w)
1170 CODE:
1171 START (async, w);
1172
1173void ev_async_stop (ev_async *w)
1174 CODE:
1175 STOP (async, w);
1176
1177void DESTROY (ev_async *w)
1178 CODE:
1179 STOP (async, w);
1180 e_destroy (w);
1181
1182void ev_async_send (ev_async *w)
1183 C_ARGS: e_loop (w), w
1184
1185SV *ev_async_async_pending (ev_async *w)
1186 CODE:
1187 RETVAL = boolSV (ev_async_pending (w));
1188 OUTPUT:
1189 RETVAL
1190
1120MODULE = EV PACKAGE = EV::Loop PREFIX = ev_loop_ 1191MODULE = EV PACKAGE = EV::Loop PREFIX = ev_
1121 1192
1122SV *new (SV *klass, unsigned int flags = ev_supported_backends ()) 1193SV *new (SV *klass, unsigned int flags = 0)
1123 CODE: 1194 CODE:
1124{ 1195{
1125 struct ev_loop *loop = ev_loop_new (flags); 1196 struct ev_loop *loop = ev_loop_new (flags);
1126 1197
1127 if (!loop) 1198 if (!loop)
1134 1205
1135void DESTROY (struct ev_loop *loop) 1206void DESTROY (struct ev_loop *loop)
1136 CODE: 1207 CODE:
1137 if (loop != evapi.default_loop) /* global destruction sucks */ 1208 if (loop != evapi.default_loop) /* global destruction sucks */
1138 ev_loop_destroy (loop); 1209 ev_loop_destroy (loop);
1210
1211void ev_loop_fork (struct ev_loop *loop)
1212
1213NV ev_now (struct ev_loop *loop)
1214
1215void ev_set_io_collect_interval (struct ev_loop *loop, NV interval)
1216
1217void ev_set_timeout_collect_interval (struct ev_loop *loop, NV interval)
1218
1219unsigned int ev_backend (struct ev_loop *loop)
1220
1221unsigned int ev_loop_count (struct ev_loop *loop)
1222
1223void ev_loop (struct ev_loop *loop, int flags = 0)
1224
1225void ev_unloop (struct ev_loop *loop, int how = 1)
1226
1227void ev_feed_fd_event (struct ev_loop *loop, int fd, int revents = EV_NONE)
1228
1229#if 0
1230
1231void ev_feed_signal_event (struct ev_loop *loop, SV *signal)
1232 CODE:
1233{
1234 Signal signum = sv_signum (signal);
1235 CHECK_SIG (signal, signum);
1236
1237 ev_feed_signal_event (loop, signum);
1238}
1239
1240#endif
1139 1241
1140ev_io *io (struct ev_loop *loop, SV *fh, int events, SV *cb) 1242ev_io *io (struct ev_loop *loop, SV *fh, int events, SV *cb)
1141 ALIAS: 1243 ALIAS:
1142 io_ns = 1 1244 io_ns = 1
1143 CODE: 1245 CODE:
1151 if (!ix) START (io, RETVAL); 1253 if (!ix) START (io, RETVAL);
1152} 1254}
1153 OUTPUT: 1255 OUTPUT:
1154 RETVAL 1256 RETVAL
1155 1257
1258ev_timer *timer (struct ev_loop *loop, NV after, NV repeat, SV *cb)
1259 ALIAS:
1260 timer_ns = 1
1261 INIT:
1262 CHECK_REPEAT (repeat);
1263 CODE:
1264 RETVAL = e_new (sizeof (ev_timer), cb, ST (0));
1265 ev_timer_set (RETVAL, after, repeat);
1266 if (!ix) START (timer, RETVAL);
1267 OUTPUT:
1268 RETVAL
1269
1270SV *periodic (struct ev_loop *loop, NV at, NV interval, SV *reschedule_cb, SV *cb)
1271 ALIAS:
1272 periodic_ns = 1
1273 INIT:
1274 CHECK_REPEAT (interval);
1275 CODE:
1276{
1277 ev_periodic *w;
1278 w = e_new (sizeof (ev_periodic), cb, ST (0));
1279 w->fh = SvTRUE (reschedule_cb) ? newSVsv (reschedule_cb) : 0;
1280 ev_periodic_set (w, at, interval, w->fh ? e_periodic_cb : 0);
1281 RETVAL = e_bless ((ev_watcher *)w, stash_periodic);
1282 if (!ix) START (periodic, w);
1283}
1284 OUTPUT:
1285 RETVAL
1286
1287#if 0
1288
1289ev_signal *signal (struct ev_loop *loop, SV *signal, SV *cb)
1290 ALIAS:
1291 signal_ns = 1
1292 CODE:
1293{
1294 Signal signum = sv_signum (signal);
1295 CHECK_SIG (signal, signum);
1296
1297 RETVAL = e_new (sizeof (ev_signal), cb, ST (0));
1298 ev_signal_set (RETVAL, signum);
1299 if (!ix) START (signal, RETVAL);
1300}
1301 OUTPUT:
1302 RETVAL
1303
1304#endif
1305
1306ev_idle *idle (struct ev_loop *loop, SV *cb)
1307 ALIAS:
1308 idle_ns = 1
1309 CODE:
1310 RETVAL = e_new (sizeof (ev_idle), cb, ST (0));
1311 ev_idle_set (RETVAL);
1312 if (!ix) START (idle, RETVAL);
1313 OUTPUT:
1314 RETVAL
1315
1316ev_prepare *prepare (struct ev_loop *loop, SV *cb)
1317 ALIAS:
1318 prepare_ns = 1
1319 CODE:
1320 RETVAL = e_new (sizeof (ev_prepare), cb, ST (0));
1321 ev_prepare_set (RETVAL);
1322 if (!ix) START (prepare, RETVAL);
1323 OUTPUT:
1324 RETVAL
1325
1326ev_check *check (struct ev_loop *loop, SV *cb)
1327 ALIAS:
1328 check_ns = 1
1329 CODE:
1330 RETVAL = e_new (sizeof (ev_check), cb, ST (0));
1331 ev_check_set (RETVAL);
1332 if (!ix) START (check, RETVAL);
1333 OUTPUT:
1334 RETVAL
1335
1336ev_fork *fork (struct ev_loop *loop, SV *cb)
1337 ALIAS:
1338 fork_ns = 1
1339 CODE:
1340 RETVAL = e_new (sizeof (ev_fork), cb, ST (0));
1341 ev_fork_set (RETVAL);
1342 if (!ix) START (fork, RETVAL);
1343 OUTPUT:
1344 RETVAL
1345
1346ev_child *child (struct ev_loop *loop, int pid, int trace, SV *cb)
1347 ALIAS:
1348 child_ns = 1
1349 CODE:
1350 RETVAL = e_new (sizeof (ev_child), cb, ST (0));
1351 ev_child_set (RETVAL, pid, trace);
1352 if (!ix) START (child, RETVAL);
1353 OUTPUT:
1354 RETVAL
1355
1356ev_stat *stat (struct ev_loop *loop, SV *path, NV interval, SV *cb)
1357 ALIAS:
1358 stat_ns = 1
1359 CODE:
1360 RETVAL = e_new (sizeof (ev_stat), cb, ST (0));
1361 RETVAL->fh = newSVsv (path);
1362 ev_stat_set (RETVAL, SvPVbyte_nolen (RETVAL->fh), interval);
1363 if (!ix) START (stat, RETVAL);
1364 OUTPUT:
1365 RETVAL
1366
1367ev_embed *embed (struct ev_loop *loop, struct ev_loop *other, SV *cb = &PL_sv_undef)
1368 ALIAS:
1369 embed_ns = 1
1370 CODE:
1371{
1372 if (!(ev_backend (other) & ev_embeddable_backends ()))
1373 croak ("passed loop is not embeddable via EV::embed,");
1374
1375 RETVAL = e_new (sizeof (ev_embed), cb, ST (0));
1376 RETVAL->fh = newSVsv (ST (1));
1377 ev_embed_set (RETVAL, other);
1378
1379 if (!SvOK (cb)) ev_set_cb (RETVAL, 0);
1380
1381 if (!ix) START (embed, RETVAL);
1382}
1383 OUTPUT:
1384 RETVAL
1385
1386ev_async *async (struct ev_loop *loop, SV *cb)
1387 ALIAS:
1388 async_ns = 1
1389 CODE:
1390 RETVAL = e_new (sizeof (ev_async), cb, ST (0));
1391 ev_async_set (RETVAL);
1392 if (!ix) START (async, RETVAL);
1393 OUTPUT:
1394 RETVAL
1395
1396void once (struct ev_loop *loop, SV *fh, int events, SV *timeout, SV *cb)
1397 CODE:
1398 ev_once (
1399 loop,
1400 sv_fileno (fh), events,
1401 SvOK (timeout) ? SvNV (timeout) : -1.,
1402 e_once_cb,
1403 newSVsv (cb)
1404 );
1405

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines