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

Comparing EV/EV.xs (file contents):
Revision 1.177 by root, Wed Jan 22 02:10:13 2020 UTC vs.
Revision 1.180 by root, Wed Jan 22 23:17:31 2020 UTC

82 do { \ 82 do { \
83 REF (w); \ 83 REF (w); \
84 ev_ ## type ## _stop (e_loop (w), w); \ 84 ev_ ## type ## _stop (e_loop (w), w); \
85 } while (0) 85 } while (0)
86 86
87#define PAUSE(type) \
88 do { \
89 int active = ev_is_active (w); \
90 if (active) STOP (type, w)
91
92#define RESUME(type) \
93 if (active) START (type, w); \
94 } while (0)
95
96
87#define RESET(type,w,seta) \ 97#define RESET(type,w,seta) \
88 do { \ 98 PAUSE (type); \
89 int active = ev_is_active (w); \
90 if (active) STOP (type, w); \
91 ev_ ## type ## _set seta; \ 99 ev_ ## type ## _set seta; \
92 if (active) START (type, w); \ 100 RESUME (type)
93 } while (0)
94 101
95typedef int Signal; 102typedef int Signal;
96 103
97/* horrible... */ 104/* horrible... */
98#define CHECK_SIGNAL_CAN_START(w) \ 105#define CHECK_SIGNAL_CAN_START(w) \
862 C_ARGS: e_loop (w), w 869 C_ARGS: e_loop (w), w
863 870
864void ev_feed_event (ev_watcher *w, int revents = EV_NONE) 871void ev_feed_event (ev_watcher *w, int revents = EV_NONE)
865 C_ARGS: e_loop (w), w, revents 872 C_ARGS: e_loop (w), w, revents
866 873
867int keepalive (ev_watcher *w, int new_value = 0) 874int keepalive (ev_watcher *w, SV *new_value = NO_INIT)
868 CODE: 875 CODE:
869{ 876{
870 RETVAL = w->e_flags & WFLAG_KEEPALIVE; 877 RETVAL = w->e_flags & WFLAG_KEEPALIVE;
871 new_value = new_value ? WFLAG_KEEPALIVE : 0;
872 878
873 if (items > 1 && ((new_value ^ w->e_flags) & WFLAG_KEEPALIVE)) 879 if (items > 1)
874 { 880 {
881 int value = SvTRUE (new_value) ? WFLAG_KEEPALIVE : 0;
882
883 if ((value ^ w->e_flags) & WFLAG_KEEPALIVE)
884 {
875 w->e_flags = (w->e_flags & ~WFLAG_KEEPALIVE) | new_value; 885 w->e_flags = (w->e_flags & ~WFLAG_KEEPALIVE) | value;
876 REF (w); 886 REF (w);
877 UNREF (w); 887 UNREF (w);
888 }
878 } 889 }
879} 890}
880 OUTPUT: 891 OUTPUT:
881 RETVAL 892 RETVAL
882 893
883SV *cb (ev_watcher *w, SV *new_cb = 0) 894SV *cb (ev_watcher *w, SV *new_cb = NO_INIT)
884 CODE: 895 CODE:
885{ 896{
886 if (items > 1) 897 if (items > 1)
887 { 898 {
888 new_cb = s_get_cv_croak (new_cb); 899 new_cb = s_get_cv_croak (new_cb);
893 RETVAL = newRV_inc (w->cb_sv); 904 RETVAL = newRV_inc (w->cb_sv);
894} 905}
895 OUTPUT: 906 OUTPUT:
896 RETVAL 907 RETVAL
897 908
898SV *data (ev_watcher *w, SV *new_data = 0) 909SV *data (ev_watcher *w, SV *new_data = NO_INIT)
899 CODE: 910 CODE:
900{ 911{
901 RETVAL = w->data ? newSVsv (w->data) : &PL_sv_undef; 912 RETVAL = w->data ? newSVsv (w->data) : &PL_sv_undef;
902 913
903 if (items > 1) 914 if (items > 1)
913 CODE: 924 CODE:
914 RETVAL = newRV_inc (w->loop); 925 RETVAL = newRV_inc (w->loop);
915 OUTPUT: 926 OUTPUT:
916 RETVAL 927 RETVAL
917 928
918int priority (ev_watcher *w, int new_priority = 0) 929int priority (ev_watcher *w, SV *new_priority = NO_INIT)
919 CODE: 930 CODE:
920{ 931{
921 RETVAL = w->priority; 932 RETVAL = w->priority;
922 933
923 if (items > 1) 934 if (items > 1)
931 XPUSHs (ST (0)); 942 XPUSHs (ST (0));
932 PUTBACK; 943 PUTBACK;
933 call_method ("stop", G_DISCARD | G_VOID); 944 call_method ("stop", G_DISCARD | G_VOID);
934 } 945 }
935 946
936 ev_set_priority (w, new_priority); 947 ev_set_priority (w, SvIV (new_priority));
937 948
938 if (active) 949 if (active)
939 { 950 {
940 PUSHMARK (SP); 951 PUSHMARK (SP);
941 XPUSHs (ST (0)); 952 XPUSHs (ST (0));
970 981
971 sv_setsv (e_fh (w), fh); 982 sv_setsv (e_fh (w), fh);
972 RESET (io, w, (w, fd, events)); 983 RESET (io, w, (w, fd, events));
973} 984}
974 985
975SV *fh (ev_io *w, SV *new_fh = 0) 986SV *fh (ev_io *w, SV *new_fh = NO_INIT)
976 CODE: 987 CODE:
977{ 988{
978 if (items > 1) 989 if (items > 1)
979 { 990 {
980 int fd = s_fileno (new_fh, w->events & EV_WRITE); 991 int fd = s_fileno (new_fh, w->events & EV_WRITE);
989 RETVAL = newSVsv (e_fh (w)); 1000 RETVAL = newSVsv (e_fh (w));
990} 1001}
991 OUTPUT: 1002 OUTPUT:
992 RETVAL 1003 RETVAL
993 1004
994int events (ev_io *w, int new_events = EV_UNDEF) 1005int events (ev_io *w, int new_events = NO_INIT)
995 CODE: 1006 CODE:
996{ 1007{
997 RETVAL = w->events; 1008 RETVAL = w->events;
998 1009
999 if (items > 1) 1010 if (items > 1 && (new_events ^ w->events) & (EV_READ | EV_WRITE))
1000 { 1011 {
1001 int active = ev_is_active (w); 1012 PAUSE (io);
1002 if (active) STOP (io, w);
1003 ev_io_modify (w, new_events); 1013 ev_io_modify (w, new_events);
1004 if (active) START (io, w); 1014 RESUME (io);
1005 } 1015 }
1006} 1016}
1007 OUTPUT: 1017 OUTPUT:
1008 RETVAL 1018 RETVAL
1009 1019
1029 CHECK_SIG (signal, signum); 1039 CHECK_SIG (signal, signum);
1030 1040
1031 RESET_SIGNAL (w, (w, signum)); 1041 RESET_SIGNAL (w, (w, signum));
1032} 1042}
1033 1043
1034int signal (ev_signal *w, SV *new_signal = 0) 1044int signal (ev_signal *w, SV *new_signal = NO_INIT)
1035 CODE: 1045 CODE:
1036{ 1046{
1037 RETVAL = w->signum; 1047 RETVAL = w->signum;
1038 1048
1039 if (items > 1) 1049 if (items > 1)
1040 { 1050 {
1041 Signal signum = s_signum (new_signal); 1051 Signal signum = s_signum (new_signal);
1042 CHECK_SIG (new_signal, signum); 1052 CHECK_SIG (new_signal, signum);
1043
1044 RESET_SIGNAL (w, (w, signum)); 1053 RESET_SIGNAL (w, (w, signum));
1045 } 1054 }
1046} 1055}
1047 OUTPUT: 1056 OUTPUT:
1048 RETVAL 1057 RETVAL
1059 CODE: 1068 CODE:
1060 STOP (timer, w); 1069 STOP (timer, w);
1061 1070
1062void ev_timer_again (ev_timer *w, NV repeat = NO_INIT) 1071void ev_timer_again (ev_timer *w, NV repeat = NO_INIT)
1063 CODE: 1072 CODE:
1073{
1064 if (items > 1) 1074 if (items > 1)
1075 {
1076 CHECK_REPEAT (repeat);
1065 w->repeat = repeat; 1077 w->repeat = repeat;
1066 CHECK_REPEAT (w->repeat); 1078 }
1079
1067 ev_timer_again (e_loop (w), w); 1080 ev_timer_again (e_loop (w), w);
1068 UNREF (w); 1081 UNREF (w);
1082}
1069 1083
1070NV ev_timer_remaining (ev_timer *w) 1084NV ev_timer_remaining (ev_timer *w)
1071 C_ARGS: e_loop (w), w 1085 C_ARGS: e_loop (w), w
1072 1086
1073void DESTROY (ev_timer *w) 1087void DESTROY (ev_timer *w)
1079 INIT: 1093 INIT:
1080 CHECK_REPEAT (repeat); 1094 CHECK_REPEAT (repeat);
1081 CODE: 1095 CODE:
1082 RESET (timer, w, (w, after, repeat)); 1096 RESET (timer, w, (w, after, repeat));
1083 1097
1098NV repeat (ev_timer *w, SV *new_repeat = NO_INIT)
1099 CODE:
1100 RETVAL = w->repeat;
1101 if (items > 1)
1102 {
1103 NV repeat = SvNV (new_repeat);
1104 CHECK_REPEAT (repeat);
1105 w->repeat = repeat;
1106 }
1107 OUTPUT:
1108 RETVAL
1109
1084MODULE = EV PACKAGE = EV::Periodic PREFIX = ev_periodic_ 1110MODULE = EV PACKAGE = EV::Periodic PREFIX = ev_periodic_
1085 1111
1086void ev_periodic_start (ev_periodic *w) 1112void ev_periodic_start (ev_periodic *w)
1087 INIT: 1113 INIT:
1088 CHECK_REPEAT (w->interval); 1114 CHECK_REPEAT (w->interval);
1118 CODE: 1144 CODE:
1119 RETVAL = ev_periodic_at (w); 1145 RETVAL = ev_periodic_at (w);
1120 OUTPUT: 1146 OUTPUT:
1121 RETVAL 1147 RETVAL
1122 1148
1149NV offset (ev_periodic *w, SV *new_offset = NO_INIT)
1150 CODE:
1151 RETVAL = w->offset;
1152 if (items > 1)
1153 w->offset = SvNV (new_offset);
1154 OUTPUT:
1155 RETVAL
1156
1157NV interval (ev_periodic *w, SV *new_interval = NO_INIT)
1158 CODE:
1159 RETVAL = w->interval;
1160 if (items > 1)
1161 {
1162 NV interval = SvNV (new_interval);
1163 CHECK_REPEAT (interval);
1164 w->interval = interval;
1165 }
1166 OUTPUT:
1167 RETVAL
1168
1169SV *reschedule_cb (ev_periodic *w, SV *new_reschedule_cb = NO_INIT)
1170 CODE:
1171 RETVAL = e_fh (w) ? e_fh (w) : &PL_sv_undef;
1172 if (items > 1)
1173 {
1174 sv_2mortal (RETVAL);
1175 e_fh (w) = SvTRUE (new_reschedule_cb) ? newSVsv (new_reschedule_cb) : 0;
1176 }
1177 OUTPUT:
1178 RETVAL
1179
1123MODULE = EV PACKAGE = EV::Idle PREFIX = ev_idle_ 1180MODULE = EV PACKAGE = EV::Idle PREFIX = ev_idle_
1124 1181
1125void ev_idle_start (ev_idle *w) 1182void ev_idle_start (ev_idle *w)
1126 CODE: 1183 CODE:
1127 START (idle, w); 1184 START (idle, w);
1260{ 1317{
1261 sv_setsv (e_fh (w), path); 1318 sv_setsv (e_fh (w), path);
1262 RESET (stat, w, (w, SvPVbyte_nolen (e_fh (w)), interval)); 1319 RESET (stat, w, (w, SvPVbyte_nolen (e_fh (w)), interval));
1263} 1320}
1264 1321
1265SV *path (ev_stat *w, SV *new_path = 0) 1322SV *path (ev_stat *w, SV *new_path = NO_INIT)
1266 CODE: 1323 CODE:
1267{ 1324{
1268 RETVAL = SvREFCNT_inc (e_fh (w)); 1325 RETVAL = e_fh (w) ? e_fh (w) : &PL_sv_undef;
1269 1326
1270 if (items > 1) 1327 if (items > 1)
1271 { 1328 {
1272 SvREFCNT_dec (e_fh (w)); 1329 sv_2mortal (RETVAL);
1273 e_fh (w) = newSVsv (new_path); 1330 e_fh (w) = newSVsv (new_path);
1274 RESET (stat, w, (w, SvPVbyte_nolen (e_fh (w)), w->interval)); 1331 RESET (stat, w, (w, SvPVbyte_nolen (e_fh (w)), w->interval));
1275 } 1332 }
1276} 1333}
1277 OUTPUT: 1334 OUTPUT:
1278 RETVAL 1335 RETVAL
1279 1336
1280NV interval (ev_stat *w, NV new_interval = 0.) 1337NV interval (ev_stat *w, SV *new_interval = NO_INIT)
1281 CODE: 1338 CODE:
1282{
1283 RETVAL = w->interval; 1339 RETVAL = w->interval;
1284
1285 if (items > 1) 1340 if (items > 1)
1286 RESET (stat, w, (w, SvPVbyte_nolen (e_fh (w)), new_interval)); 1341 {
1287} 1342 PAUSE (stat);
1343 w->interval = SvNV (new_interval);
1344 RESUME (stat);
1345 }
1288 OUTPUT: 1346 OUTPUT:
1289 RETVAL 1347 RETVAL
1290 1348
1291void prev (ev_stat *w) 1349void prev (ev_stat *w)
1292 ALIAS: 1350 ALIAS:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines