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

Comparing EV/EV.xs (file contents):
Revision 1.161 by root, Wed Dec 5 17:18:47 2012 UTC vs.
Revision 1.182 by root, Tue Feb 18 16:50:21 2020 UTC

1#include "EXTERN.h" 1#include "EXTERN.h"
2#include "perl.h" 2#include "perl.h"
3#include "XSUB.h" 3#include "XSUB.h"
4 4
5/* fix perl api breakage */ 5/* fix perl api breakage */
6#ifndef WIN32
6#undef signal 7# undef signal
7#undef sigaction 8# undef sigaction
9#endif
8 10
9#include "schmorp.h" 11#include "schmorp.h"
10 12
11/* old API compatibility */ 13/* old API compatibility */
12static int 14static int
13sv_fileno (SV *fh) 15sv_fileno (SV *fh)
14{ 16{
15 return s_fileno (fh, 0); 17 return s_fileno (fh, 0);
16} 18}
17 19
20#ifndef GvCV_set
21# define GvCV_set(gv,cv) GvCV (gv) = cv
22#endif
23
24#if EV_ENABLE_ASSERTIONS
25# undef NDEBUG
26#else
27# define NDEBUG 1
28#endif
29
30/* make sure we get a real assert, not perl's incompatible version */
31#undef assert
32#include <assert.h>
33
18#define EV_STANDALONE 1 34#define EV_STANDALONE 1
19#define EV_PROTOTYPES 1 35#define EV_PROTOTYPES 1
20#define EV_USE_CLOCK_SYSCALL 0 /* as long as we need pthreads anyways... */
21#define EV_USE_NANOSLEEP EV_USE_MONOTONIC 36#define EV_USE_NANOSLEEP EV_USE_MONOTONIC
22#define EV_USE_FLOOR 1 37#define EV_USE_FLOOR 1
23#define EV_API_STATIC 38#define EV_API_STATIC
24#define EV_H <ev.h> 39#define EV_H "../libev/ev.h"
25#define EV_CONFIG_H error 40#define EV_CONFIG_H error
26#include "EV/EVAPI.h" 41#include "EV/EVAPI.h"
27 42
28#define EV_SELECT_IS_WINSOCKET 0 43#define EV_SELECT_IS_WINSOCKET 0
29#ifdef _WIN32 44#ifdef _WIN32
32# define fd_mask Perl_fd_mask 47# define fd_mask Perl_fd_mask
33#endif 48#endif
34/* due to bugs in OS X we have to use libev/ explicitly here */ 49/* due to bugs in OS X we have to use libev/ explicitly here */
35#include "libev/ev.c" 50#include "libev/ev.c"
36 51
37#if !defined _WIN32 && !defined _MINIX 52#if !defined _WIN32 && !defined __minix && !EV_NO_ATFORK
38# include <pthread.h> 53# include <pthread.h>
39#endif 54#endif
40 55
41#define e_loop(w) INT2PTR (struct ev_loop *, SvIVX (((ev_watcher *)(w))->loop)) 56#define e_loop(w) INT2PTR (struct ev_loop *, SvIVX (((ev_watcher *)(w))->loop))
42#define e_flags(w) ((ev_watcher *)(w))->e_flags 57#define e_flags(w) ((ev_watcher *)(w))->e_flags
72 do { \ 87 do { \
73 REF (w); \ 88 REF (w); \
74 ev_ ## type ## _stop (e_loop (w), w); \ 89 ev_ ## type ## _stop (e_loop (w), w); \
75 } while (0) 90 } while (0)
76 91
92#define PAUSE(type) \
93 do { \
94 int active = ev_is_active (w); \
95 if (active) STOP (type, w)
96
97#define RESUME(type) \
98 if (active) START (type, w); \
99 } while (0)
100
101
77#define RESET(type,w,seta) \ 102#define RESET(type,w,seta) \
78 do { \ 103 PAUSE (type); \
79 int active = ev_is_active (w); \
80 if (active) STOP (type, w); \
81 ev_ ## type ## _set seta; \ 104 ev_ ## type ## _set seta; \
82 if (active) START (type, w); \ 105 RESUME (type)
83 } while (0)
84 106
85typedef int Signal; 107typedef int Signal;
86 108
87/* horrible... */ 109/* horrible... */
88#define CHECK_SIGNAL_CAN_START(w) \ 110#define CHECK_SIGNAL_CAN_START(w) \
192 dSP; 214 dSP;
193 I32 mark = SP - PL_stack_base; 215 I32 mark = SP - PL_stack_base;
194 SV *sv_self, *sv_events; 216 SV *sv_self, *sv_events;
195 217
196 /* libev might have stopped the watcher */ 218 /* libev might have stopped the watcher */
197 if (expect_false (w->e_flags & WFLAG_UNREFED) 219 if (ecb_expect_false (w->e_flags & WFLAG_UNREFED)
198 && !ev_is_active (w)) 220 && !ev_is_active (w))
199 REF (w); 221 REF (w);
200 222
201 if (expect_true (sv_self_cache)) 223 if (ecb_expect_true (sv_self_cache))
202 { 224 {
203 sv_self = sv_self_cache; sv_self_cache = 0; 225 sv_self = sv_self_cache; sv_self_cache = 0;
204 SvRV_set (sv_self, SvREFCNT_inc_NN (w->self)); 226 SvRV_set (sv_self, SvREFCNT_inc_NN (w->self));
205 } 227 }
206 else 228 else
207 { 229 {
208 sv_self = newRV_inc (w->self); /* e_self (w) MUST be blessed by now */ 230 sv_self = newRV_inc (w->self); /* e_self (w) MUST be blessed by now */
209 SvREADONLY_on (sv_self); 231 SvREADONLY_on (sv_self);
210 } 232 }
211 233
212 if (expect_true (sv_events_cache)) 234 if (ecb_expect_true (sv_events_cache))
213 { 235 {
214 sv_events = sv_events_cache; sv_events_cache = 0; 236 sv_events = sv_events_cache; sv_events_cache = 0;
215 SvIV_set (sv_events, revents); 237 SvIV_set (sv_events, revents);
216 SvIOK_only (sv_events); 238 SvIOK_only (sv_events);
217 } 239 }
227 PUSHs (sv_events); 249 PUSHs (sv_events);
228 250
229 PUTBACK; 251 PUTBACK;
230 call_sv (w->cb_sv, G_DISCARD | G_VOID | G_EVAL); 252 call_sv (w->cb_sv, G_DISCARD | G_VOID | G_EVAL);
231 253
232 if (expect_false (SvREFCNT (sv_self) != 1 || sv_self_cache)) 254 if (ecb_expect_false (SvREFCNT (sv_self) != 1 || sv_self_cache))
233 SvREFCNT_dec (sv_self); 255 SvREFCNT_dec (sv_self);
234 else 256 else
235 { 257 {
236 SvREFCNT_dec (SvRV (sv_self)); 258 SvREFCNT_dec (SvRV (sv_self));
237 SvRV_set (sv_self, &PL_sv_undef); 259 SvRV_set (sv_self, &PL_sv_undef);
238 sv_self_cache = sv_self; 260 sv_self_cache = sv_self;
239 } 261 }
240 262
241 if (expect_false (SvREFCNT (sv_events) != 1 || sv_events_cache)) 263 if (ecb_expect_false (SvREFCNT (sv_events) != 1 || sv_events_cache))
242 SvREFCNT_dec (sv_events); 264 SvREFCNT_dec (sv_events);
243 else 265 else
244 sv_events_cache = sv_events; 266 sv_events_cache = sv_events;
245 267
246 if (expect_false (SvTRUE (ERRSV))) 268 if (ecb_expect_false (SvTRUE (ERRSV)))
247 { 269 {
248 SPAGAIN; 270 SPAGAIN;
249 PUSHMARK (SP); 271 PUSHMARK (SP);
250 PUTBACK; 272 PUTBACK;
251 call_sv (get_sv ("EV::DIED", 1), G_DISCARD | G_VOID | G_EVAL | G_KEEPERR); 273 call_sv (get_sv ("EV::DIED", 1), G_DISCARD | G_VOID | G_EVAL | G_KEEPERR);
382 const_iv (EV_, SIGNAL) 404 const_iv (EV_, SIGNAL)
383 const_iv (EV_, CHILD) 405 const_iv (EV_, CHILD)
384 const_iv (EV_, STAT) 406 const_iv (EV_, STAT)
385 const_iv (EV_, IDLE) 407 const_iv (EV_, IDLE)
386 const_iv (EV_, PREPARE) 408 const_iv (EV_, PREPARE)
387 const_iv (EV_, CHECK) 409 /*const_iv (EV_, CHECK) needs special tretament */
388 const_iv (EV_, EMBED) 410 const_iv (EV_, EMBED)
389 const_iv (EV_, FORK) 411 const_iv (EV_, FORK)
390 const_iv (EV_, CLEANUP) 412 const_iv (EV_, CLEANUP)
391 const_iv (EV_, ASYNC) 413 const_iv (EV_, ASYNC)
392 const_iv (EV_, CUSTOM) 414 const_iv (EV_, CUSTOM)
426#endif 448#endif
427 }; 449 };
428 450
429 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ > const_iv; civ--) 451 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ > const_iv; civ--)
430 newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv)); 452 newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv));
453
454 /* since this clashes with perl CHECK blocks, */
455 /* but we are interested in constants, */
456 /* and not blocks, we treat CHECK specially. */
457 {
458 /* the local $^W = 0 takes care of the warning */
459 CV *cv = newCONSTSUB (stash, "CHECK", newSViv (EV_CHECK));
460 /* now we need to re-set the gv, in case it was hijacked */
461 GvCV_set (gv_fetchpv ("EV::CHECK", GV_ADD, SVt_PVCV), cv);
462 }
431 463
432 stash_loop = gv_stashpv ("EV::Loop" , 1); 464 stash_loop = gv_stashpv ("EV::Loop" , 1);
433 stash_watcher = gv_stashpv ("EV::Watcher" , 1); 465 stash_watcher = gv_stashpv ("EV::Watcher" , 1);
434 stash_io = gv_stashpv ("EV::IO" , 1); 466 stash_io = gv_stashpv ("EV::IO" , 1);
435 stash_timer = gv_stashpv ("EV::Timer" , 1); 467 stash_timer = gv_stashpv ("EV::Timer" , 1);
518 evapi.invoke = ev_invoke; 550 evapi.invoke = ev_invoke;
519 551
520 sv_setiv (sv, (IV)&evapi); 552 sv_setiv (sv, (IV)&evapi);
521 SvREADONLY_on (sv); 553 SvREADONLY_on (sv);
522 } 554 }
523#if !defined _WIN32 && !defined _MINIX 555#if !defined _WIN32 && !defined _MINIX && !EV_NO_ATFORK
556/* unfortunately, musl neither implements the linux standard base,
557/* nor makes itself detectable via macros. yeah, right... */
558#if __linux && (__GLIBC__ || __UCLIBC__)
559 int __register_atfork(void (*prepare) (void), void (*parent) (void), void (*child) (void), void * __dso_handle);
560 __register_atfork (0, 0, default_fork, 0);
561#else
524 pthread_atfork (0, 0, default_fork); 562 pthread_atfork (0, 0, default_fork);
563#endif
525#endif 564#endif
526} 565}
527 566
528SV *ev_default_loop (unsigned int flags = 0) 567SV *ev_default_loop (unsigned int flags = 0)
529 CODE: 568 CODE:
560NV ev_time () 599NV ev_time ()
561 600
562void ev_feed_signal (SV *signal) 601void ev_feed_signal (SV *signal)
563 CODE: 602 CODE:
564{ 603{
565 Signal signum = s_signum (signal); 604 Signal signum = s_signum (signal);
566 CHECK_SIG (signal, signum); 605 CHECK_SIG (signal, signum);
567 606
568 ev_feed_signal (signum); 607 ev_feed_signal (signum);
569} 608}
570 609
602 C_ARGS: evapi.default_loop, interval 641 C_ARGS: evapi.default_loop, interval
603 642
604void ev_set_timeout_collect_interval (NV interval) 643void ev_set_timeout_collect_interval (NV interval)
605 C_ARGS: evapi.default_loop, interval 644 C_ARGS: evapi.default_loop, interval
606 645
607void ev_run (int flags = 0) 646int ev_run (int flags = 0)
608 ALIAS: 647 ALIAS:
609 loop = 1 648 loop = 1
610 C_ARGS: evapi.default_loop, flags 649 C_ARGS: evapi.default_loop, flags
611 650
612void ev_break (int how = EVBREAK_ONE) 651void ev_break (int how = EVBREAK_ONE)
618 C_ARGS: evapi.default_loop, fd, revents 657 C_ARGS: evapi.default_loop, fd, revents
619 658
620void ev_feed_signal_event (SV *signal) 659void ev_feed_signal_event (SV *signal)
621 CODE: 660 CODE:
622{ 661{
623 Signal signum = s_signum (signal); 662 Signal signum = s_signum (signal);
624 CHECK_SIG (signal, signum); 663 CHECK_SIG (signal, signum);
625 664
626 ev_feed_signal_event (evapi.default_loop, signum); 665 ev_feed_signal_event (evapi.default_loop, signum);
627} 666}
628 667
672 periodic_ns = 1 711 periodic_ns = 1
673 INIT: 712 INIT:
674 CHECK_REPEAT (interval); 713 CHECK_REPEAT (interval);
675 CODE: 714 CODE:
676{ 715{
677 ev_periodic *w; 716 ev_periodic *w;
678 w = e_new (sizeof (ev_periodic), cb, default_loop_sv); 717 w = e_new (sizeof (ev_periodic), cb, default_loop_sv);
679 e_fh (w) = SvTRUE (reschedule_cb) ? newSVsv (reschedule_cb) : 0; 718 e_fh (w) = SvTRUE (reschedule_cb) ? newSVsv (reschedule_cb) : 0;
680 ev_periodic_set (w, at, interval, e_fh (w) ? e_periodic_cb : 0); 719 ev_periodic_set (w, at, interval, e_fh (w) ? e_periodic_cb : 0);
681 RETVAL = e_bless ((ev_watcher *)w, stash_periodic); 720 RETVAL = e_bless ((ev_watcher *)w, stash_periodic);
682 if (!ix) START (periodic, w); 721 if (!ix) START (periodic, w);
687ev_signal *signal (SV *signal, SV *cb) 726ev_signal *signal (SV *signal, SV *cb)
688 ALIAS: 727 ALIAS:
689 signal_ns = 1 728 signal_ns = 1
690 CODE: 729 CODE:
691{ 730{
692 Signal signum = s_signum (signal); 731 Signal signum = s_signum (signal);
693 CHECK_SIG (signal, signum); 732 CHECK_SIG (signal, signum);
694 733
695 RETVAL = e_new (sizeof (ev_signal), cb, default_loop_sv); 734 RETVAL = e_new (sizeof (ev_signal), cb, default_loop_sv);
696 ev_signal_set (RETVAL, signum); 735 ev_signal_set (RETVAL, signum);
697 if (!ix) START_SIGNAL (RETVAL); 736 if (!ix) START_SIGNAL (RETVAL);
835 C_ARGS: e_loop (w), w 874 C_ARGS: e_loop (w), w
836 875
837void ev_feed_event (ev_watcher *w, int revents = EV_NONE) 876void ev_feed_event (ev_watcher *w, int revents = EV_NONE)
838 C_ARGS: e_loop (w), w, revents 877 C_ARGS: e_loop (w), w, revents
839 878
840int keepalive (ev_watcher *w, int new_value = 0) 879int keepalive (ev_watcher *w, SV *new_value = NO_INIT)
841 CODE: 880 CODE:
842{ 881{
843 RETVAL = w->e_flags & WFLAG_KEEPALIVE; 882 RETVAL = w->e_flags & WFLAG_KEEPALIVE;
844 new_value = new_value ? WFLAG_KEEPALIVE : 0;
845 883
846 if (items > 1 && ((new_value ^ w->e_flags) & WFLAG_KEEPALIVE)) 884 if (items > 1)
847 { 885 {
886 int value = SvTRUE (new_value) ? WFLAG_KEEPALIVE : 0;
887
888 if ((value ^ w->e_flags) & WFLAG_KEEPALIVE)
889 {
848 w->e_flags = (w->e_flags & ~WFLAG_KEEPALIVE) | new_value; 890 w->e_flags = (w->e_flags & ~WFLAG_KEEPALIVE) | value;
849 REF (w); 891 REF (w);
850 UNREF (w); 892 UNREF (w);
893 }
851 } 894 }
852} 895}
853 OUTPUT: 896 OUTPUT:
854 RETVAL 897 RETVAL
855 898
856SV *cb (ev_watcher *w, SV *new_cb = 0) 899SV *cb (ev_watcher *w, SV *new_cb = NO_INIT)
857 CODE: 900 CODE:
858{ 901{
859 if (items > 1) 902 if (items > 1)
860 { 903 {
861 new_cb = s_get_cv_croak (new_cb); 904 new_cb = s_get_cv_croak (new_cb);
866 RETVAL = newRV_inc (w->cb_sv); 909 RETVAL = newRV_inc (w->cb_sv);
867} 910}
868 OUTPUT: 911 OUTPUT:
869 RETVAL 912 RETVAL
870 913
871SV *data (ev_watcher *w, SV *new_data = 0) 914SV *data (ev_watcher *w, SV *new_data = NO_INIT)
872 CODE: 915 CODE:
873{ 916{
874 RETVAL = w->data ? newSVsv (w->data) : &PL_sv_undef; 917 RETVAL = w->data ? newSVsv (w->data) : &PL_sv_undef;
875 918
876 if (items > 1) 919 if (items > 1)
886 CODE: 929 CODE:
887 RETVAL = newRV_inc (w->loop); 930 RETVAL = newRV_inc (w->loop);
888 OUTPUT: 931 OUTPUT:
889 RETVAL 932 RETVAL
890 933
891int priority (ev_watcher *w, int new_priority = 0) 934int priority (ev_watcher *w, SV *new_priority = NO_INIT)
892 CODE: 935 CODE:
893{ 936{
894 RETVAL = w->priority; 937 RETVAL = w->priority;
895 938
896 if (items > 1) 939 if (items > 1)
904 XPUSHs (ST (0)); 947 XPUSHs (ST (0));
905 PUTBACK; 948 PUTBACK;
906 call_method ("stop", G_DISCARD | G_VOID); 949 call_method ("stop", G_DISCARD | G_VOID);
907 } 950 }
908 951
909 ev_set_priority (w, new_priority); 952 ev_set_priority (w, SvIV (new_priority));
910 953
911 if (active) 954 if (active)
912 { 955 {
913 PUSHMARK (SP); 956 PUSHMARK (SP);
914 XPUSHs (ST (0)); 957 XPUSHs (ST (0));
943 986
944 sv_setsv (e_fh (w), fh); 987 sv_setsv (e_fh (w), fh);
945 RESET (io, w, (w, fd, events)); 988 RESET (io, w, (w, fd, events));
946} 989}
947 990
948SV *fh (ev_io *w, SV *new_fh = 0) 991SV *fh (ev_io *w, SV *new_fh = NO_INIT)
949 CODE: 992 CODE:
950{ 993{
951 if (items > 1) 994 if (items > 1)
952 { 995 {
953 int fd = s_fileno (new_fh, w->events & EV_WRITE); 996 int fd = s_fileno (new_fh, w->events & EV_WRITE);
962 RETVAL = newSVsv (e_fh (w)); 1005 RETVAL = newSVsv (e_fh (w));
963} 1006}
964 OUTPUT: 1007 OUTPUT:
965 RETVAL 1008 RETVAL
966 1009
967int events (ev_io *w, int new_events = EV_UNDEF) 1010int events (ev_io *w, int new_events = NO_INIT)
968 CODE: 1011 CODE:
969{ 1012{
970 RETVAL = w->events; 1013 RETVAL = w->events;
971 1014
972 if (items > 1) 1015 if (items > 1 && (new_events ^ w->events) & (EV_READ | EV_WRITE))
973 RESET (io, w, (w, w->fd, new_events)); 1016 {
1017 PAUSE (io);
1018 ev_io_modify (w, new_events);
1019 RESUME (io);
1020 }
974} 1021}
975 OUTPUT: 1022 OUTPUT:
976 RETVAL 1023 RETVAL
977 1024
978MODULE = EV PACKAGE = EV::Signal PREFIX = ev_signal_ 1025MODULE = EV PACKAGE = EV::Signal PREFIX = ev_signal_
997 CHECK_SIG (signal, signum); 1044 CHECK_SIG (signal, signum);
998 1045
999 RESET_SIGNAL (w, (w, signum)); 1046 RESET_SIGNAL (w, (w, signum));
1000} 1047}
1001 1048
1002int signal (ev_signal *w, SV *new_signal = 0) 1049int signal (ev_signal *w, SV *new_signal = NO_INIT)
1003 CODE: 1050 CODE:
1004{ 1051{
1005 RETVAL = w->signum; 1052 RETVAL = w->signum;
1006 1053
1007 if (items > 1) 1054 if (items > 1)
1008 { 1055 {
1009 Signal signum = s_signum (new_signal); 1056 Signal signum = s_signum (new_signal);
1010 CHECK_SIG (new_signal, signum); 1057 CHECK_SIG (new_signal, signum);
1011
1012 RESET_SIGNAL (w, (w, signum)); 1058 RESET_SIGNAL (w, (w, signum));
1013 } 1059 }
1014} 1060}
1015 OUTPUT: 1061 OUTPUT:
1016 RETVAL 1062 RETVAL
1025 1071
1026void ev_timer_stop (ev_timer *w) 1072void ev_timer_stop (ev_timer *w)
1027 CODE: 1073 CODE:
1028 STOP (timer, w); 1074 STOP (timer, w);
1029 1075
1030void ev_timer_again (ev_timer *w) 1076void ev_timer_again (ev_timer *w, NV repeat = NO_INIT)
1031 INIT:
1032 CHECK_REPEAT (w->repeat);
1033 CODE: 1077 CODE:
1078{
1079 if (items > 1)
1080 {
1081 CHECK_REPEAT (repeat);
1082 w->repeat = repeat;
1083 }
1084
1034 ev_timer_again (e_loop (w), w); 1085 ev_timer_again (e_loop (w), w);
1035 UNREF (w); 1086 UNREF (w);
1087}
1036 1088
1037NV ev_timer_remaining (ev_timer *w) 1089NV ev_timer_remaining (ev_timer *w)
1038 C_ARGS: e_loop (w), w 1090 C_ARGS: e_loop (w), w
1039 1091
1040void DESTROY (ev_timer *w) 1092void DESTROY (ev_timer *w)
1046 INIT: 1098 INIT:
1047 CHECK_REPEAT (repeat); 1099 CHECK_REPEAT (repeat);
1048 CODE: 1100 CODE:
1049 RESET (timer, w, (w, after, repeat)); 1101 RESET (timer, w, (w, after, repeat));
1050 1102
1103NV repeat (ev_timer *w, SV *new_repeat = NO_INIT)
1104 CODE:
1105 RETVAL = w->repeat;
1106 if (items > 1)
1107 {
1108 NV repeat = SvNV (new_repeat);
1109 CHECK_REPEAT (repeat);
1110 w->repeat = repeat;
1111 }
1112 OUTPUT:
1113 RETVAL
1114
1051MODULE = EV PACKAGE = EV::Periodic PREFIX = ev_periodic_ 1115MODULE = EV PACKAGE = EV::Periodic PREFIX = ev_periodic_
1052 1116
1053void ev_periodic_start (ev_periodic *w) 1117void ev_periodic_start (ev_periodic *w)
1054 INIT: 1118 INIT:
1055 CHECK_REPEAT (w->interval); 1119 CHECK_REPEAT (w->interval);
1085 CODE: 1149 CODE:
1086 RETVAL = ev_periodic_at (w); 1150 RETVAL = ev_periodic_at (w);
1087 OUTPUT: 1151 OUTPUT:
1088 RETVAL 1152 RETVAL
1089 1153
1154NV offset (ev_periodic *w, SV *new_offset = NO_INIT)
1155 CODE:
1156 RETVAL = w->offset;
1157 if (items > 1)
1158 w->offset = SvNV (new_offset);
1159 OUTPUT:
1160 RETVAL
1161
1162NV interval (ev_periodic *w, SV *new_interval = NO_INIT)
1163 CODE:
1164 RETVAL = w->interval;
1165 if (items > 1)
1166 {
1167 NV interval = SvNV (new_interval);
1168 CHECK_REPEAT (interval);
1169 w->interval = interval;
1170 }
1171 OUTPUT:
1172 RETVAL
1173
1174SV *reschedule_cb (ev_periodic *w, SV *new_reschedule_cb = NO_INIT)
1175 CODE:
1176 RETVAL = e_fh (w) ? e_fh (w) : &PL_sv_undef;
1177 if (items > 1)
1178 {
1179 sv_2mortal (RETVAL);
1180 e_fh (w) = SvTRUE (new_reschedule_cb) ? newSVsv (new_reschedule_cb) : 0;
1181 }
1182 OUTPUT:
1183 RETVAL
1184
1090MODULE = EV PACKAGE = EV::Idle PREFIX = ev_idle_ 1185MODULE = EV PACKAGE = EV::Idle PREFIX = ev_idle_
1091 1186
1092void ev_idle_start (ev_idle *w) 1187void ev_idle_start (ev_idle *w)
1093 CODE: 1188 CODE:
1094 START (idle, w); 1189 START (idle, w);
1227{ 1322{
1228 sv_setsv (e_fh (w), path); 1323 sv_setsv (e_fh (w), path);
1229 RESET (stat, w, (w, SvPVbyte_nolen (e_fh (w)), interval)); 1324 RESET (stat, w, (w, SvPVbyte_nolen (e_fh (w)), interval));
1230} 1325}
1231 1326
1232SV *path (ev_stat *w, SV *new_path = 0) 1327SV *path (ev_stat *w, SV *new_path = NO_INIT)
1233 CODE: 1328 CODE:
1234{ 1329{
1235 RETVAL = SvREFCNT_inc (e_fh (w)); 1330 RETVAL = e_fh (w) ? e_fh (w) : &PL_sv_undef;
1236 1331
1237 if (items > 1) 1332 if (items > 1)
1238 { 1333 {
1239 SvREFCNT_dec (e_fh (w)); 1334 sv_2mortal (RETVAL);
1240 e_fh (w) = newSVsv (new_path); 1335 e_fh (w) = newSVsv (new_path);
1241 RESET (stat, w, (w, SvPVbyte_nolen (e_fh (w)), w->interval)); 1336 RESET (stat, w, (w, SvPVbyte_nolen (e_fh (w)), w->interval));
1242 } 1337 }
1243} 1338}
1244 OUTPUT: 1339 OUTPUT:
1245 RETVAL 1340 RETVAL
1246 1341
1247NV interval (ev_stat *w, NV new_interval = 0.) 1342NV interval (ev_stat *w, SV *new_interval = NO_INIT)
1248 CODE: 1343 CODE:
1249{
1250 RETVAL = w->interval; 1344 RETVAL = w->interval;
1251
1252 if (items > 1) 1345 if (items > 1)
1253 RESET (stat, w, (w, SvPVbyte_nolen (e_fh (w)), new_interval)); 1346 {
1254} 1347 PAUSE (stat);
1348 w->interval = SvNV (new_interval);
1349 RESUME (stat);
1350 }
1255 OUTPUT: 1351 OUTPUT:
1256 RETVAL 1352 RETVAL
1257 1353
1258void prev (ev_stat *w) 1354void prev (ev_stat *w)
1259 ALIAS: 1355 ALIAS:
1406 1502
1407unsigned int ev_depth (struct ev_loop *loop) 1503unsigned int ev_depth (struct ev_loop *loop)
1408 ALIAS: 1504 ALIAS:
1409 loop_depth = 1 1505 loop_depth = 1
1410 1506
1411void ev_run (struct ev_loop *loop, int flags = 0) 1507int ev_run (struct ev_loop *loop, int flags = 0)
1412 ALIAS: 1508 ALIAS:
1413 loop = 1 1509 loop = 1
1414 1510
1415void ev_break (struct ev_loop *loop, int how = 1) 1511void ev_break (struct ev_loop *loop, int how = 1)
1416 ALIAS: 1512 ALIAS:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines