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

Comparing EV/EV.xs (file contents):
Revision 1.131 by root, Sun Jul 19 20:39:54 2009 UTC vs.
Revision 1.138 by root, Wed Apr 14 00:17:22 2010 UTC

13sv_fileno (SV *fh) 13sv_fileno (SV *fh)
14{ 14{
15 return s_fileno (fh, 0); 15 return s_fileno (fh, 0);
16} 16}
17 17
18#define EV_STANDALONE 1
18#define EV_PROTOTYPES 1 19#define EV_PROTOTYPES 1
19#define EV_USE_NANOSLEEP EV_USE_MONOTONIC 20#define EV_USE_NANOSLEEP EV_USE_MONOTONIC
20#define EV_H <ev.h> 21#define EV_H <ev.h>
22#define EV_CONFIG_H error
21#include "EV/EVAPI.h" 23#include "EV/EVAPI.h"
22 24
23#define EV_SELECT_IS_WINSOCKET 0 25#define EV_SELECT_IS_WINSOCKET 0
24#ifdef _WIN32 26#ifdef _WIN32
25# define EV_SELECT_USE_FD_SET 0 27# define EV_SELECT_USE_FD_SET 0
31 33
32#ifndef _WIN32 34#ifndef _WIN32
33# include <pthread.h> 35# include <pthread.h>
34#endif 36#endif
35 37
36#define e_loop(w) INT2PTR (struct ev_loop *, SvIVX ((w)->loop)) 38#define e_loop(w) INT2PTR (struct ev_loop *, SvIVX (((ev_watcher *)(w))->loop))
39#define e_flags(w) ((ev_watcher *)(w))->e_flags
40#define e_self(w) ((ev_watcher *)(w))->self
41#define e_fh(w) ((ev_watcher *)(w))->fh
42#define e_data(w) ((ev_watcher *)(w))->data
37 43
38#define WFLAG_KEEPALIVE 1 44#define WFLAG_KEEPALIVE 1
39#define WFLAG_UNREFED 2 /* has been unref'ed */ 45#define WFLAG_UNREFED 2 /* has been unref'ed */
40 46
41#define UNREF(w) \ 47#define UNREF(w) \
42 if (!((w)->e_flags & (WFLAG_KEEPALIVE | WFLAG_UNREFED)) \ 48 if (!(e_flags (w) & (WFLAG_KEEPALIVE | WFLAG_UNREFED)) \
43 && ev_is_active (w)) \ 49 && ev_is_active (w)) \
44 { \ 50 { \
45 ev_unref (e_loop (w)); \ 51 ev_unref (e_loop (w)); \
46 (w)->e_flags |= WFLAG_UNREFED; \ 52 e_flags (w) |= WFLAG_UNREFED; \
47 } 53 }
48 54
49#define REF(w) \ 55#define REF(w) \
50 if ((w)->e_flags & WFLAG_UNREFED) \ 56 if (e_flags (w) & WFLAG_UNREFED) \
51 { \ 57 { \
52 (w)->e_flags &= ~WFLAG_UNREFED; \ 58 e_flags (w) &= ~WFLAG_UNREFED; \
53 ev_ref (e_loop (w)); \ 59 ev_ref (e_loop (w)); \
54 } 60 }
55 61
56#define START(type,w) \ 62#define START(type,w) \
57 do { \ 63 do { \
64 REF (w); \ 70 REF (w); \
65 ev_ ## type ## _stop (e_loop (w), w); \ 71 ev_ ## type ## _stop (e_loop (w), w); \
66 } while (0) 72 } while (0)
67 73
68#define RESET(type,w,seta) \ 74#define RESET(type,w,seta) \
69 do { \ 75 do { \
70 int active = ev_is_active (w); \ 76 int active = ev_is_active (w); \
71 if (active) STOP (type, w); \ 77 if (active) STOP (type, w); \
72 ev_ ## type ## _set seta; \ 78 ev_ ## type ## _set seta; \
73 if (active) START (type, w); \ 79 if (active) START (type, w); \
74 } while (0) 80 } while (0)
75 81
76typedef int Signal; 82typedef int Signal;
83
84/* horrible... */
85#define CHECK_SIGNAL_CAN_START(w) \
86 do { \
87 /* dive into the internals of libev to avoid aborting in libev */ \
88 if (signals [(w)->signum - 1].loop \
89 && signals [(w)->signum - 1].loop != e_loop (w)) \
90 croak ("unable to start signal watcher, signal %d already registered in another loop", w->signum); \
91 } while (0)
92
93#define START_SIGNAL(w) \
94 do { \
95 CHECK_SIGNAL_CAN_START (w); \
96 START (signal, w); \
97 } while (0) \
98
99#define RESET_SIGNAL(w,seta) \
100 do { \
101 int active = ev_is_active (w); \
102 if (active) STOP (signal, w); \
103 ev_ ## signal ## _set seta; \
104 if (active) START_SIGNAL (w); \
105 } while (0)
77 106
78static SV *default_loop_sv; 107static SV *default_loop_sv;
79 108
80static struct EVAPI evapi; 109static struct EVAPI evapi;
81 110
98///////////////////////////////////////////////////////////////////////////// 127/////////////////////////////////////////////////////////////////////////////
99// Event 128// Event
100 129
101static void e_cb (EV_P_ ev_watcher *w, int revents); 130static void e_cb (EV_P_ ev_watcher *w, int revents);
102 131
103static void * 132void *
104e_new (int size, SV *cb_sv, SV *loop) 133e_new (int size, SV *cb_sv, SV *loop)
105{ 134{
106 SV *cv = cb_sv ? s_get_cv_croak (cb_sv) : 0; 135 SV *cv = cb_sv ? s_get_cv_croak (cb_sv) : 0;
107 ev_watcher *w; 136 ev_watcher *w;
108 SV *self = NEWSV (0, size); 137 SV *self = NEWSV (0, size);
170 sv_self = sv_self_cache; sv_self_cache = 0; 199 sv_self = sv_self_cache; sv_self_cache = 0;
171 SvRV_set (sv_self, SvREFCNT_inc_NN (w->self)); 200 SvRV_set (sv_self, SvREFCNT_inc_NN (w->self));
172 } 201 }
173 else 202 else
174 { 203 {
175 sv_self = newRV_inc (w->self); /* w->self MUST be blessed by now */ 204 sv_self = newRV_inc (w->self); /* e_self (w) MUST be blessed by now */
176 SvREADONLY_on (sv_self); 205 SvREADONLY_on (sv_self);
177 } 206 }
178 207
179 if (expect_true (sv_events_cache)) 208 if (expect_true (sv_events_cache))
180 { 209 {
271 ENTER; 300 ENTER;
272 SAVETMPS; 301 SAVETMPS;
273 302
274 PUSHMARK (SP); 303 PUSHMARK (SP);
275 EXTEND (SP, 2); 304 EXTEND (SP, 2);
276 PUSHs (newRV_inc (w->self)); /* w->self MUST be blessed by now */ 305 PUSHs (newRV_inc (e_self (w))); /* e_self (w) MUST be blessed by now */
277 PUSHs (newSVnv (now)); 306 PUSHs (newSVnv (now));
278 307
279 PUTBACK; 308 PUTBACK;
280 count = call_sv (w->fh, G_SCALAR | G_EVAL); 309 count = call_sv (w->fh, G_SCALAR | G_EVAL);
281 SPAGAIN; 310 SPAGAIN;
335 const_iv (EV_, UNDEF) 364 const_iv (EV_, UNDEF)
336 const_iv (EV_, NONE) 365 const_iv (EV_, NONE)
337 const_iv (EV_, READ) 366 const_iv (EV_, READ)
338 const_iv (EV_, WRITE) 367 const_iv (EV_, WRITE)
339 const_iv (EV_, IO) 368 const_iv (EV_, IO)
340 const_iv (EV_, TIMEOUT) 369 const_iv (EV_, TIMEOUT) /* deprecated */
341 const_iv (EV_, TIMER) 370 const_iv (EV_, TIMER)
342 const_iv (EV_, PERIODIC) 371 const_iv (EV_, PERIODIC)
343 const_iv (EV_, SIGNAL) 372 const_iv (EV_, SIGNAL)
344 const_iv (EV_, CHILD) 373 const_iv (EV_, CHILD)
345 const_iv (EV_, STAT) 374 const_iv (EV_, STAT)
363 const_iv (EV, BACKEND_POLL) 392 const_iv (EV, BACKEND_POLL)
364 const_iv (EV, BACKEND_EPOLL) 393 const_iv (EV, BACKEND_EPOLL)
365 const_iv (EV, BACKEND_KQUEUE) 394 const_iv (EV, BACKEND_KQUEUE)
366 const_iv (EV, BACKEND_DEVPOLL) 395 const_iv (EV, BACKEND_DEVPOLL)
367 const_iv (EV, BACKEND_PORT) 396 const_iv (EV, BACKEND_PORT)
397 const_iv (EV, BACKEND_ALL)
368 const_iv (EV, FLAG_AUTO) 398 const_iv (EV, FLAG_AUTO)
399 const_iv (EV, FLAG_FORKCHECK)
400 const_iv (EV, FLAG_SIGNALFD)
369 const_iv (EV, FLAG_NOENV) 401 const_iv (EV, FLAG_NOENV)
402 const_iv (EV, FLAG_NOSIGFD) /* compatibility, always 0 */
370 const_iv (EV, FLAG_FORKCHECK) 403 const_iv (EV, FLAG_NOINOTIFY)
371 404
372 const_iv (EV_, VERSION_MAJOR) 405 const_iv (EV_, VERSION_MAJOR)
373 const_iv (EV_, VERSION_MINOR) 406 const_iv (EV_, VERSION_MINOR)
374 }; 407 };
375 408
406 evapi.time_ = ev_time; 439 evapi.time_ = ev_time;
407 evapi.sleep_ = ev_sleep; 440 evapi.sleep_ = ev_sleep;
408 evapi.loop_new = ev_loop_new; 441 evapi.loop_new = ev_loop_new;
409 evapi.loop_destroy = ev_loop_destroy; 442 evapi.loop_destroy = ev_loop_destroy;
410 evapi.loop_fork = ev_loop_fork; 443 evapi.loop_fork = ev_loop_fork;
411 evapi.loop_count = ev_loop_count; 444 evapi.iteration = ev_iteration;
412 evapi.loop_depth = ev_loop_depth; 445 evapi.depth = ev_depth;
413 evapi.set_userdata = ev_set_userdata; 446 evapi.set_userdata = ev_set_userdata;
414 evapi.userdata = ev_userdata; 447 evapi.userdata = ev_userdata;
415 evapi.now = ev_now; 448 evapi.now = ev_now;
416 evapi.now_update = ev_now_update; 449 evapi.now_update = ev_now_update;
417 evapi.suspend = ev_suspend; 450 evapi.suspend = ev_suspend;
418 evapi.resume = ev_resume; 451 evapi.resume = ev_resume;
419 evapi.backend = ev_backend; 452 evapi.backend = ev_backend;
420 evapi.unloop = ev_unloop; 453 evapi.unloop = ev_unloop;
421 evapi.invoke_pending = ev_invoke_pending; 454 evapi.invoke_pending = ev_invoke_pending;
422 evapi.pending_count = ev_pending_count; 455 evapi.pending_count = ev_pending_count;
456 evapi.verify = ev_verify;
423 evapi.set_loop_release_cb = ev_set_loop_release_cb; 457 evapi.set_loop_release_cb = ev_set_loop_release_cb;
424 evapi.set_invoke_pending_cb= ev_set_invoke_pending_cb; 458 evapi.set_invoke_pending_cb= ev_set_invoke_pending_cb;
425 evapi.ref = ev_ref; 459 evapi.ref = ev_ref;
426 evapi.unref = ev_unref; 460 evapi.unref = ev_unref;
427 evapi.loop = ev_loop; 461 evapi.loop = ev_loop;
513 C_ARGS: evapi.default_loop 547 C_ARGS: evapi.default_loop
514 548
515unsigned int ev_backend () 549unsigned int ev_backend ()
516 C_ARGS: evapi.default_loop 550 C_ARGS: evapi.default_loop
517 551
518void ev_loop_verify () 552void ev_verify ()
519 C_ARGS: evapi.default_loop 553 C_ARGS: evapi.default_loop
520 554
521unsigned int ev_loop_count () 555unsigned int ev_iteration ()
522 C_ARGS: evapi.default_loop 556 C_ARGS: evapi.default_loop
523 557
524unsigned int ev_loop_depth () 558unsigned int ev_depth ()
525 C_ARGS: evapi.default_loop 559 C_ARGS: evapi.default_loop
526 560
527void ev_set_io_collect_interval (NV interval) 561void ev_set_io_collect_interval (NV interval)
528 C_ARGS: evapi.default_loop, interval 562 C_ARGS: evapi.default_loop, interval
529 563
555 C_ARGS: evapi.default_loop 589 C_ARGS: evapi.default_loop
556 590
557ev_io *io (SV *fh, int events, SV *cb) 591ev_io *io (SV *fh, int events, SV *cb)
558 ALIAS: 592 ALIAS:
559 io_ns = 1 593 io_ns = 1
594 _ae_io = 2
560 CODE: 595 CODE:
561{ 596{
562 int fd = s_fileno (fh, events & EV_WRITE); 597 int fd = s_fileno (fh, events & EV_WRITE);
563 CHECK_FD (fh, fd); 598 CHECK_FD (fh, fd);
564 599
600 if (ix == 2)
601 {
602 ix = 0;
603 events = events ? EV_WRITE : EV_READ;
604 }
605
565 RETVAL = e_new (sizeof (ev_io), cb, default_loop_sv); 606 RETVAL = e_new (sizeof (ev_io), cb, default_loop_sv);
566 RETVAL->fh = newSVsv (fh); 607 e_fh (RETVAL) = newSVsv (fh);
567 ev_io_set (RETVAL, fd, events); 608 ev_io_set (RETVAL, fd, events);
568 if (!ix) START (io, RETVAL); 609 if (!ix) START (io, RETVAL);
569} 610}
570 OUTPUT: 611 OUTPUT:
571 RETVAL 612 RETVAL
589 CHECK_REPEAT (interval); 630 CHECK_REPEAT (interval);
590 CODE: 631 CODE:
591{ 632{
592 ev_periodic *w; 633 ev_periodic *w;
593 w = e_new (sizeof (ev_periodic), cb, default_loop_sv); 634 w = e_new (sizeof (ev_periodic), cb, default_loop_sv);
594 w->fh = SvTRUE (reschedule_cb) ? newSVsv (reschedule_cb) : 0; 635 e_fh (w) = SvTRUE (reschedule_cb) ? newSVsv (reschedule_cb) : 0;
595 ev_periodic_set (w, at, interval, w->fh ? e_periodic_cb : 0); 636 ev_periodic_set (w, at, interval, e_fh (w) ? e_periodic_cb : 0);
596 RETVAL = e_bless ((ev_watcher *)w, stash_periodic); 637 RETVAL = e_bless ((ev_watcher *)w, stash_periodic);
597 if (!ix) START (periodic, w); 638 if (!ix) START (periodic, w);
598} 639}
599 OUTPUT: 640 OUTPUT:
600 RETVAL 641 RETVAL
607 Signal signum = s_signum (signal); 648 Signal signum = s_signum (signal);
608 CHECK_SIG (signal, signum); 649 CHECK_SIG (signal, signum);
609 650
610 RETVAL = e_new (sizeof (ev_signal), cb, default_loop_sv); 651 RETVAL = e_new (sizeof (ev_signal), cb, default_loop_sv);
611 ev_signal_set (RETVAL, signum); 652 ev_signal_set (RETVAL, signum);
612 if (!ix) START (signal, RETVAL); 653 if (!ix) START_SIGNAL (RETVAL);
613} 654}
614 OUTPUT: 655 OUTPUT:
615 RETVAL 656 RETVAL
616 657
617ev_idle *idle (SV *cb) 658ev_idle *idle (SV *cb)
667ev_stat *stat (SV *path, NV interval, SV *cb) 708ev_stat *stat (SV *path, NV interval, SV *cb)
668 ALIAS: 709 ALIAS:
669 stat_ns = 1 710 stat_ns = 1
670 CODE: 711 CODE:
671 RETVAL = e_new (sizeof (ev_stat), cb, default_loop_sv); 712 RETVAL = e_new (sizeof (ev_stat), cb, default_loop_sv);
672 RETVAL->fh = newSVsv (path); 713 e_fh (RETVAL) = newSVsv (path);
673 ev_stat_set (RETVAL, SvPVbyte_nolen (RETVAL->fh), interval); 714 ev_stat_set (RETVAL, SvPVbyte_nolen (e_fh (RETVAL)), interval);
674 if (!ix) START (stat, RETVAL); 715 if (!ix) START (stat, RETVAL);
675 OUTPUT: 716 OUTPUT:
676 RETVAL 717 RETVAL
677 718
678ev_embed *embed (struct ev_loop *loop, SV *cb = 0) 719ev_embed *embed (struct ev_loop *loop, SV *cb = 0)
682{ 723{
683 if (!(ev_backend (loop) & ev_embeddable_backends ())) 724 if (!(ev_backend (loop) & ev_embeddable_backends ()))
684 croak ("passed loop is not embeddable via EV::embed,"); 725 croak ("passed loop is not embeddable via EV::embed,");
685 726
686 RETVAL = e_new (sizeof (ev_embed), cb, default_loop_sv); 727 RETVAL = e_new (sizeof (ev_embed), cb, default_loop_sv);
687 RETVAL->fh = newSVsv (ST (0)); 728 e_fh (RETVAL) = newSVsv (ST (0));
688 ev_embed_set (RETVAL, loop); 729 ev_embed_set (RETVAL, loop);
689 if (!ix) START (embed, RETVAL); 730 if (!ix) START (embed, RETVAL);
690} 731}
691 OUTPUT: 732 OUTPUT:
692 RETVAL 733 RETVAL
830 CODE: 871 CODE:
831{ 872{
832 int fd = s_fileno (fh, events & EV_WRITE); 873 int fd = s_fileno (fh, events & EV_WRITE);
833 CHECK_FD (fh, fd); 874 CHECK_FD (fh, fd);
834 875
835 sv_setsv (w->fh, fh); 876 sv_setsv (e_fh (w), fh);
836 RESET (io, w, (w, fd, events)); 877 RESET (io, w, (w, fd, events));
837} 878}
838 879
839SV *fh (ev_io *w, SV *new_fh = 0) 880SV *fh (ev_io *w, SV *new_fh = 0)
840 CODE: 881 CODE:
842 if (items > 1) 883 if (items > 1)
843 { 884 {
844 int fd = s_fileno (new_fh, w->events & EV_WRITE); 885 int fd = s_fileno (new_fh, w->events & EV_WRITE);
845 CHECK_FD (new_fh, fd); 886 CHECK_FD (new_fh, fd);
846 887
847 RETVAL = w->fh; 888 RETVAL = e_fh (w);
848 w->fh = newSVsv (new_fh); 889 e_fh (w) = newSVsv (new_fh);
849 890
850 RESET (io, w, (w, fd, w->events)); 891 RESET (io, w, (w, fd, w->events));
851 } 892 }
852 else 893 else
853 RETVAL = newSVsv (w->fh); 894 RETVAL = newSVsv (e_fh (w));
854} 895}
855 OUTPUT: 896 OUTPUT:
856 RETVAL 897 RETVAL
857 898
858int events (ev_io *w, int new_events = EV_UNDEF) 899int events (ev_io *w, int new_events = EV_UNDEF)
868 909
869MODULE = EV PACKAGE = EV::Signal PREFIX = ev_signal_ 910MODULE = EV PACKAGE = EV::Signal PREFIX = ev_signal_
870 911
871void ev_signal_start (ev_signal *w) 912void ev_signal_start (ev_signal *w)
872 CODE: 913 CODE:
873 START (signal, w); 914 START_SIGNAL (w);
874 915
875void ev_signal_stop (ev_signal *w) 916void ev_signal_stop (ev_signal *w)
876 CODE: 917 CODE:
877 STOP (signal, w); 918 STOP (signal, w);
878 919
885 CODE: 926 CODE:
886{ 927{
887 Signal signum = s_signum (signal); 928 Signal signum = s_signum (signal);
888 CHECK_SIG (signal, signum); 929 CHECK_SIG (signal, signum);
889 930
890 RESET (signal, w, (w, signum)); 931 RESET_SIGNAL (w, (w, signum));
891} 932}
892 933
893int signal (ev_signal *w, SV *new_signal = 0) 934int signal (ev_signal *w, SV *new_signal = 0)
894 CODE: 935 CODE:
895{ 936{
898 if (items > 1) 939 if (items > 1)
899 { 940 {
900 Signal signum = s_signum (new_signal); 941 Signal signum = s_signum (new_signal);
901 CHECK_SIG (new_signal, signum); 942 CHECK_SIG (new_signal, signum);
902 943
903 RESET (signal, w, (w, signum)); 944 RESET_SIGNAL (w, (w, signum));
904 } 945 }
905} 946}
906 OUTPUT: 947 OUTPUT:
907 RETVAL 948 RETVAL
908 949
964void set (ev_periodic *w, NV at, NV interval = 0., SV *reschedule_cb = &PL_sv_undef) 1005void set (ev_periodic *w, NV at, NV interval = 0., SV *reschedule_cb = &PL_sv_undef)
965 INIT: 1006 INIT:
966 CHECK_REPEAT (interval); 1007 CHECK_REPEAT (interval);
967 CODE: 1008 CODE:
968{ 1009{
969 SvREFCNT_dec (w->fh); 1010 SvREFCNT_dec (e_fh (w));
970 w->fh = SvTRUE (reschedule_cb) ? newSVsv (reschedule_cb) : 0; 1011 e_fh (w) = SvTRUE (reschedule_cb) ? newSVsv (reschedule_cb) : 0;
971 1012
972 RESET (periodic, w, (w, at, interval, w->fh ? e_periodic_cb : 0)); 1013 RESET (periodic, w, (w, at, interval, e_fh (w) ? e_periodic_cb : 0));
973} 1014}
974 1015
975NV at (ev_periodic *w) 1016NV at (ev_periodic *w)
976 CODE: 1017 CODE:
977 RETVAL = ev_periodic_at (w); 1018 RETVAL = ev_periodic_at (w);
1084 e_destroy (w); 1125 e_destroy (w);
1085 1126
1086void set (ev_stat *w, SV *path, NV interval) 1127void set (ev_stat *w, SV *path, NV interval)
1087 CODE: 1128 CODE:
1088{ 1129{
1089 sv_setsv (w->fh, path); 1130 sv_setsv (e_fh (w), path);
1090 RESET (stat, w, (w, SvPVbyte_nolen (w->fh), interval)); 1131 RESET (stat, w, (w, SvPVbyte_nolen (e_fh (w)), interval));
1091} 1132}
1092 1133
1093SV *path (ev_stat *w, SV *new_path = 0) 1134SV *path (ev_stat *w, SV *new_path = 0)
1094 CODE: 1135 CODE:
1095{ 1136{
1096 RETVAL = SvREFCNT_inc (w->fh); 1137 RETVAL = SvREFCNT_inc (e_fh (w));
1097 1138
1098 if (items > 1) 1139 if (items > 1)
1099 { 1140 {
1100 SvREFCNT_dec (w->fh); 1141 SvREFCNT_dec (e_fh (w));
1101 w->fh = newSVsv (new_path); 1142 e_fh (w) = newSVsv (new_path);
1102 RESET (stat, w, (w, SvPVbyte_nolen (w->fh), w->interval)); 1143 RESET (stat, w, (w, SvPVbyte_nolen (e_fh (w)), w->interval));
1103 } 1144 }
1104} 1145}
1105 OUTPUT: 1146 OUTPUT:
1106 RETVAL 1147 RETVAL
1107 1148
1109 CODE: 1150 CODE:
1110{ 1151{
1111 RETVAL = w->interval; 1152 RETVAL = w->interval;
1112 1153
1113 if (items > 1) 1154 if (items > 1)
1114 RESET (stat, w, (w, SvPVbyte_nolen (w->fh), new_interval)); 1155 RESET (stat, w, (w, SvPVbyte_nolen (e_fh (w)), new_interval));
1115} 1156}
1116 OUTPUT: 1157 OUTPUT:
1117 RETVAL 1158 RETVAL
1118 1159
1119void prev (ev_stat *w) 1160void prev (ev_stat *w)
1178 e_destroy (w); 1219 e_destroy (w);
1179 1220
1180void set (ev_embed *w, struct ev_loop *loop) 1221void set (ev_embed *w, struct ev_loop *loop)
1181 CODE: 1222 CODE:
1182{ 1223{
1183 sv_setsv (w->fh, ST (1)); 1224 sv_setsv (e_fh (w), ST (1));
1184 RESET (embed, w, (w, loop)); 1225 RESET (embed, w, (w, loop));
1185} 1226}
1186 1227
1187SV *other (ev_embed *w) 1228SV *other (ev_embed *w)
1188 CODE: 1229 CODE:
1189 RETVAL = newSVsv (w->fh); 1230 RETVAL = newSVsv (e_fh (w));
1190 OUTPUT: 1231 OUTPUT:
1191 RETVAL 1232 RETVAL
1192 1233
1193void ev_embed_sweep (ev_embed *w) 1234void ev_embed_sweep (ev_embed *w)
1194 C_ARGS: e_loop (w), w 1235 C_ARGS: e_loop (w), w
1237 if (loop != evapi.default_loop) /* global destruction sucks */ 1278 if (loop != evapi.default_loop) /* global destruction sucks */
1238 ev_loop_destroy (loop); 1279 ev_loop_destroy (loop);
1239 1280
1240void ev_loop_fork (struct ev_loop *loop) 1281void ev_loop_fork (struct ev_loop *loop)
1241 1282
1242void ev_loop_verify (struct ev_loop *loop) 1283void ev_verify (struct ev_loop *loop)
1243 1284
1244NV ev_now (struct ev_loop *loop) 1285NV ev_now (struct ev_loop *loop)
1245 1286
1246void ev_now_update (struct ev_loop *loop) 1287void ev_now_update (struct ev_loop *loop)
1247 1288
1253 1294
1254void ev_set_timeout_collect_interval (struct ev_loop *loop, NV interval) 1295void ev_set_timeout_collect_interval (struct ev_loop *loop, NV interval)
1255 1296
1256unsigned int ev_backend (struct ev_loop *loop) 1297unsigned int ev_backend (struct ev_loop *loop)
1257 1298
1258unsigned int ev_loop_count (struct ev_loop *loop) 1299unsigned int ev_iteration (struct ev_loop *loop)
1259 1300
1260unsigned int ev_loop_depth (struct ev_loop *loop) 1301unsigned int ev_depth (struct ev_loop *loop)
1261 1302
1262void ev_loop (struct ev_loop *loop, int flags = 0) 1303void ev_loop (struct ev_loop *loop, int flags = 0)
1263 1304
1264void ev_unloop (struct ev_loop *loop, int how = 1) 1305void ev_unloop (struct ev_loop *loop, int how = 1)
1265 1306
1289{ 1330{
1290 int fd = s_fileno (fh, events & EV_WRITE); 1331 int fd = s_fileno (fh, events & EV_WRITE);
1291 CHECK_FD (fh, fd); 1332 CHECK_FD (fh, fd);
1292 1333
1293 RETVAL = e_new (sizeof (ev_io), cb, ST (0)); 1334 RETVAL = e_new (sizeof (ev_io), cb, ST (0));
1294 RETVAL->fh = newSVsv (fh); 1335 e_fh (RETVAL) = newSVsv (fh);
1295 ev_io_set (RETVAL, fd, events); 1336 ev_io_set (RETVAL, fd, events);
1296 if (!ix) START (io, RETVAL); 1337 if (!ix) START (io, RETVAL);
1297} 1338}
1298 OUTPUT: 1339 OUTPUT:
1299 RETVAL 1340 RETVAL
1317 CHECK_REPEAT (interval); 1358 CHECK_REPEAT (interval);
1318 CODE: 1359 CODE:
1319{ 1360{
1320 ev_periodic *w; 1361 ev_periodic *w;
1321 w = e_new (sizeof (ev_periodic), cb, ST (0)); 1362 w = e_new (sizeof (ev_periodic), cb, ST (0));
1322 w->fh = SvTRUE (reschedule_cb) ? newSVsv (reschedule_cb) : 0; 1363 e_fh (w) = SvTRUE (reschedule_cb) ? newSVsv (reschedule_cb) : 0;
1323 ev_periodic_set (w, at, interval, w->fh ? e_periodic_cb : 0); 1364 ev_periodic_set (w, at, interval, e_fh (w) ? e_periodic_cb : 0);
1324 RETVAL = e_bless ((ev_watcher *)w, stash_periodic); 1365 RETVAL = e_bless ((ev_watcher *)w, stash_periodic);
1325 if (!ix) START (periodic, w); 1366 if (!ix) START (periodic, w);
1326} 1367}
1327 OUTPUT: 1368 OUTPUT:
1328 RETVAL 1369 RETVAL
1335 Signal signum = s_signum (signal); 1376 Signal signum = s_signum (signal);
1336 CHECK_SIG (signal, signum); 1377 CHECK_SIG (signal, signum);
1337 1378
1338 RETVAL = e_new (sizeof (ev_signal), cb, ST (0)); 1379 RETVAL = e_new (sizeof (ev_signal), cb, ST (0));
1339 ev_signal_set (RETVAL, signum); 1380 ev_signal_set (RETVAL, signum);
1340 if (!ix) START (signal, RETVAL); 1381 if (!ix) START_SIGNAL (RETVAL);
1341} 1382}
1342 OUTPUT: 1383 OUTPUT:
1343 RETVAL 1384 RETVAL
1344 1385
1345ev_idle *idle (struct ev_loop *loop, SV *cb) 1386ev_idle *idle (struct ev_loop *loop, SV *cb)
1395ev_stat *stat (struct ev_loop *loop, SV *path, NV interval, SV *cb) 1436ev_stat *stat (struct ev_loop *loop, SV *path, NV interval, SV *cb)
1396 ALIAS: 1437 ALIAS:
1397 stat_ns = 1 1438 stat_ns = 1
1398 CODE: 1439 CODE:
1399 RETVAL = e_new (sizeof (ev_stat), cb, ST (0)); 1440 RETVAL = e_new (sizeof (ev_stat), cb, ST (0));
1400 RETVAL->fh = newSVsv (path); 1441 e_fh (RETVAL) = newSVsv (path);
1401 ev_stat_set (RETVAL, SvPVbyte_nolen (RETVAL->fh), interval); 1442 ev_stat_set (RETVAL, SvPVbyte_nolen (e_fh (RETVAL)), interval);
1402 if (!ix) START (stat, RETVAL); 1443 if (!ix) START (stat, RETVAL);
1403 OUTPUT: 1444 OUTPUT:
1404 RETVAL 1445 RETVAL
1405 1446
1406ev_embed *embed (struct ev_loop *loop, struct ev_loop *other, SV *cb = 0) 1447ev_embed *embed (struct ev_loop *loop, struct ev_loop *other, SV *cb = 0)
1410{ 1451{
1411 if (!(ev_backend (other) & ev_embeddable_backends ())) 1452 if (!(ev_backend (other) & ev_embeddable_backends ()))
1412 croak ("passed loop is not embeddable via EV::embed,"); 1453 croak ("passed loop is not embeddable via EV::embed,");
1413 1454
1414 RETVAL = e_new (sizeof (ev_embed), cb, ST (0)); 1455 RETVAL = e_new (sizeof (ev_embed), cb, ST (0));
1415 RETVAL->fh = newSVsv (ST (1)); 1456 e_fh (RETVAL) = newSVsv (ST (1));
1416 ev_embed_set (RETVAL, other); 1457 ev_embed_set (RETVAL, other);
1417 if (!ix) START (embed, RETVAL); 1458 if (!ix) START (embed, RETVAL);
1418} 1459}
1419 OUTPUT: 1460 OUTPUT:
1420 RETVAL 1461 RETVAL

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines