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

Comparing EV/EV.xs (file contents):
Revision 1.176 by root, Fri Jul 12 06:18:37 2019 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 RESET (io, w, (w, w->fd, new_events)); 1011 {
1012 PAUSE (io);
1013 ev_io_modify (w, new_events);
1014 RESUME (io);
1015 }
1001} 1016}
1002 OUTPUT: 1017 OUTPUT:
1003 RETVAL 1018 RETVAL
1004 1019
1005MODULE = EV PACKAGE = EV::Signal PREFIX = ev_signal_ 1020MODULE = EV PACKAGE = EV::Signal PREFIX = ev_signal_
1024 CHECK_SIG (signal, signum); 1039 CHECK_SIG (signal, signum);
1025 1040
1026 RESET_SIGNAL (w, (w, signum)); 1041 RESET_SIGNAL (w, (w, signum));
1027} 1042}
1028 1043
1029int signal (ev_signal *w, SV *new_signal = 0) 1044int signal (ev_signal *w, SV *new_signal = NO_INIT)
1030 CODE: 1045 CODE:
1031{ 1046{
1032 RETVAL = w->signum; 1047 RETVAL = w->signum;
1033 1048
1034 if (items > 1) 1049 if (items > 1)
1035 { 1050 {
1036 Signal signum = s_signum (new_signal); 1051 Signal signum = s_signum (new_signal);
1037 CHECK_SIG (new_signal, signum); 1052 CHECK_SIG (new_signal, signum);
1038
1039 RESET_SIGNAL (w, (w, signum)); 1053 RESET_SIGNAL (w, (w, signum));
1040 } 1054 }
1041} 1055}
1042 OUTPUT: 1056 OUTPUT:
1043 RETVAL 1057 RETVAL
1054 CODE: 1068 CODE:
1055 STOP (timer, w); 1069 STOP (timer, w);
1056 1070
1057void ev_timer_again (ev_timer *w, NV repeat = NO_INIT) 1071void ev_timer_again (ev_timer *w, NV repeat = NO_INIT)
1058 CODE: 1072 CODE:
1073{
1059 if (items > 1) 1074 if (items > 1)
1075 {
1076 CHECK_REPEAT (repeat);
1060 w->repeat = repeat; 1077 w->repeat = repeat;
1061 CHECK_REPEAT (w->repeat); 1078 }
1079
1062 ev_timer_again (e_loop (w), w); 1080 ev_timer_again (e_loop (w), w);
1063 UNREF (w); 1081 UNREF (w);
1082}
1064 1083
1065NV ev_timer_remaining (ev_timer *w) 1084NV ev_timer_remaining (ev_timer *w)
1066 C_ARGS: e_loop (w), w 1085 C_ARGS: e_loop (w), w
1067 1086
1068void DESTROY (ev_timer *w) 1087void DESTROY (ev_timer *w)
1074 INIT: 1093 INIT:
1075 CHECK_REPEAT (repeat); 1094 CHECK_REPEAT (repeat);
1076 CODE: 1095 CODE:
1077 RESET (timer, w, (w, after, repeat)); 1096 RESET (timer, w, (w, after, repeat));
1078 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
1079MODULE = EV PACKAGE = EV::Periodic PREFIX = ev_periodic_ 1110MODULE = EV PACKAGE = EV::Periodic PREFIX = ev_periodic_
1080 1111
1081void ev_periodic_start (ev_periodic *w) 1112void ev_periodic_start (ev_periodic *w)
1082 INIT: 1113 INIT:
1083 CHECK_REPEAT (w->interval); 1114 CHECK_REPEAT (w->interval);
1113 CODE: 1144 CODE:
1114 RETVAL = ev_periodic_at (w); 1145 RETVAL = ev_periodic_at (w);
1115 OUTPUT: 1146 OUTPUT:
1116 RETVAL 1147 RETVAL
1117 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
1118MODULE = EV PACKAGE = EV::Idle PREFIX = ev_idle_ 1180MODULE = EV PACKAGE = EV::Idle PREFIX = ev_idle_
1119 1181
1120void ev_idle_start (ev_idle *w) 1182void ev_idle_start (ev_idle *w)
1121 CODE: 1183 CODE:
1122 START (idle, w); 1184 START (idle, w);
1255{ 1317{
1256 sv_setsv (e_fh (w), path); 1318 sv_setsv (e_fh (w), path);
1257 RESET (stat, w, (w, SvPVbyte_nolen (e_fh (w)), interval)); 1319 RESET (stat, w, (w, SvPVbyte_nolen (e_fh (w)), interval));
1258} 1320}
1259 1321
1260SV *path (ev_stat *w, SV *new_path = 0) 1322SV *path (ev_stat *w, SV *new_path = NO_INIT)
1261 CODE: 1323 CODE:
1262{ 1324{
1263 RETVAL = SvREFCNT_inc (e_fh (w)); 1325 RETVAL = e_fh (w) ? e_fh (w) : &PL_sv_undef;
1264 1326
1265 if (items > 1) 1327 if (items > 1)
1266 { 1328 {
1267 SvREFCNT_dec (e_fh (w)); 1329 sv_2mortal (RETVAL);
1268 e_fh (w) = newSVsv (new_path); 1330 e_fh (w) = newSVsv (new_path);
1269 RESET (stat, w, (w, SvPVbyte_nolen (e_fh (w)), w->interval)); 1331 RESET (stat, w, (w, SvPVbyte_nolen (e_fh (w)), w->interval));
1270 } 1332 }
1271} 1333}
1272 OUTPUT: 1334 OUTPUT:
1273 RETVAL 1335 RETVAL
1274 1336
1275NV interval (ev_stat *w, NV new_interval = 0.) 1337NV interval (ev_stat *w, SV *new_interval = NO_INIT)
1276 CODE: 1338 CODE:
1277{
1278 RETVAL = w->interval; 1339 RETVAL = w->interval;
1279
1280 if (items > 1) 1340 if (items > 1)
1281 RESET (stat, w, (w, SvPVbyte_nolen (e_fh (w)), new_interval)); 1341 {
1282} 1342 PAUSE (stat);
1343 w->interval = SvNV (new_interval);
1344 RESUME (stat);
1345 }
1283 OUTPUT: 1346 OUTPUT:
1284 RETVAL 1347 RETVAL
1285 1348
1286void prev (ev_stat *w) 1349void prev (ev_stat *w)
1287 ALIAS: 1350 ALIAS:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines