… | |
… | |
21 | # define GvCV_set(gv,cv) GvCV (gv) = cv |
21 | # define GvCV_set(gv,cv) GvCV (gv) = cv |
22 | #endif |
22 | #endif |
23 | |
23 | |
24 | #if EV_ENABLE_ASSERTIONS |
24 | #if EV_ENABLE_ASSERTIONS |
25 | # undef NDEBUG |
25 | # undef NDEBUG |
26 | # include <assert.h> |
26 | #else |
|
|
27 | # define NDEBUG 1 |
27 | #endif |
28 | #endif |
|
|
29 | |
|
|
30 | /* make sure we get a real assert, not perl's incompatible version */ |
|
|
31 | #undef assert |
|
|
32 | #include <assert.h> |
28 | |
33 | |
29 | #define EV_STANDALONE 1 |
34 | #define EV_STANDALONE 1 |
30 | #define EV_PROTOTYPES 1 |
35 | #define EV_PROTOTYPES 1 |
31 | #define EV_USE_NANOSLEEP EV_USE_MONOTONIC |
36 | #define EV_USE_NANOSLEEP EV_USE_MONOTONIC |
32 | #define EV_USE_FLOOR 1 |
37 | #define EV_USE_FLOOR 1 |
… | |
… | |
82 | do { \ |
87 | do { \ |
83 | REF (w); \ |
88 | REF (w); \ |
84 | ev_ ## type ## _stop (e_loop (w), w); \ |
89 | ev_ ## type ## _stop (e_loop (w), w); \ |
85 | } while (0) |
90 | } while (0) |
86 | |
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 | |
87 | #define RESET(type,w,seta) \ |
102 | #define RESET(type,w,seta) \ |
88 | do { \ |
103 | PAUSE (type); \ |
89 | int active = ev_is_active (w); \ |
|
|
90 | if (active) STOP (type, w); \ |
|
|
91 | ev_ ## type ## _set seta; \ |
104 | ev_ ## type ## _set seta; \ |
92 | if (active) START (type, w); \ |
105 | RESUME (type) |
93 | } while (0) |
|
|
94 | |
106 | |
95 | typedef int Signal; |
107 | typedef int Signal; |
96 | |
108 | |
97 | /* horrible... */ |
109 | /* horrible... */ |
98 | #define CHECK_SIGNAL_CAN_START(w) \ |
110 | #define CHECK_SIGNAL_CAN_START(w) \ |
… | |
… | |
862 | C_ARGS: e_loop (w), w |
874 | C_ARGS: e_loop (w), w |
863 | |
875 | |
864 | void ev_feed_event (ev_watcher *w, int revents = EV_NONE) |
876 | void ev_feed_event (ev_watcher *w, int revents = EV_NONE) |
865 | C_ARGS: e_loop (w), w, revents |
877 | C_ARGS: e_loop (w), w, revents |
866 | |
878 | |
867 | int keepalive (ev_watcher *w, int new_value = 0) |
879 | int keepalive (ev_watcher *w, SV *new_value = NO_INIT) |
868 | CODE: |
880 | CODE: |
869 | { |
881 | { |
870 | RETVAL = w->e_flags & WFLAG_KEEPALIVE; |
882 | RETVAL = w->e_flags & WFLAG_KEEPALIVE; |
871 | new_value = new_value ? WFLAG_KEEPALIVE : 0; |
|
|
872 | |
883 | |
873 | if (items > 1 && ((new_value ^ w->e_flags) & WFLAG_KEEPALIVE)) |
884 | if (items > 1) |
874 | { |
885 | { |
|
|
886 | int value = SvTRUE (new_value) ? WFLAG_KEEPALIVE : 0; |
|
|
887 | |
|
|
888 | if ((value ^ w->e_flags) & WFLAG_KEEPALIVE) |
|
|
889 | { |
875 | w->e_flags = (w->e_flags & ~WFLAG_KEEPALIVE) | new_value; |
890 | w->e_flags = (w->e_flags & ~WFLAG_KEEPALIVE) | value; |
876 | REF (w); |
891 | REF (w); |
877 | UNREF (w); |
892 | UNREF (w); |
|
|
893 | } |
878 | } |
894 | } |
879 | } |
895 | } |
880 | OUTPUT: |
896 | OUTPUT: |
881 | RETVAL |
897 | RETVAL |
882 | |
898 | |
883 | SV *cb (ev_watcher *w, SV *new_cb = 0) |
899 | SV *cb (ev_watcher *w, SV *new_cb = NO_INIT) |
884 | CODE: |
900 | CODE: |
885 | { |
901 | { |
886 | if (items > 1) |
902 | if (items > 1) |
887 | { |
903 | { |
888 | new_cb = s_get_cv_croak (new_cb); |
904 | new_cb = s_get_cv_croak (new_cb); |
… | |
… | |
893 | RETVAL = newRV_inc (w->cb_sv); |
909 | RETVAL = newRV_inc (w->cb_sv); |
894 | } |
910 | } |
895 | OUTPUT: |
911 | OUTPUT: |
896 | RETVAL |
912 | RETVAL |
897 | |
913 | |
898 | SV *data (ev_watcher *w, SV *new_data = 0) |
914 | SV *data (ev_watcher *w, SV *new_data = NO_INIT) |
899 | CODE: |
915 | CODE: |
900 | { |
916 | { |
901 | RETVAL = w->data ? newSVsv (w->data) : &PL_sv_undef; |
917 | RETVAL = w->data ? newSVsv (w->data) : &PL_sv_undef; |
902 | |
918 | |
903 | if (items > 1) |
919 | if (items > 1) |
… | |
… | |
913 | CODE: |
929 | CODE: |
914 | RETVAL = newRV_inc (w->loop); |
930 | RETVAL = newRV_inc (w->loop); |
915 | OUTPUT: |
931 | OUTPUT: |
916 | RETVAL |
932 | RETVAL |
917 | |
933 | |
918 | int priority (ev_watcher *w, int new_priority = 0) |
934 | int priority (ev_watcher *w, SV *new_priority = NO_INIT) |
919 | CODE: |
935 | CODE: |
920 | { |
936 | { |
921 | RETVAL = w->priority; |
937 | RETVAL = w->priority; |
922 | |
938 | |
923 | if (items > 1) |
939 | if (items > 1) |
… | |
… | |
931 | XPUSHs (ST (0)); |
947 | XPUSHs (ST (0)); |
932 | PUTBACK; |
948 | PUTBACK; |
933 | call_method ("stop", G_DISCARD | G_VOID); |
949 | call_method ("stop", G_DISCARD | G_VOID); |
934 | } |
950 | } |
935 | |
951 | |
936 | ev_set_priority (w, new_priority); |
952 | ev_set_priority (w, SvIV (new_priority)); |
937 | |
953 | |
938 | if (active) |
954 | if (active) |
939 | { |
955 | { |
940 | PUSHMARK (SP); |
956 | PUSHMARK (SP); |
941 | XPUSHs (ST (0)); |
957 | XPUSHs (ST (0)); |
… | |
… | |
970 | |
986 | |
971 | sv_setsv (e_fh (w), fh); |
987 | sv_setsv (e_fh (w), fh); |
972 | RESET (io, w, (w, fd, events)); |
988 | RESET (io, w, (w, fd, events)); |
973 | } |
989 | } |
974 | |
990 | |
975 | SV *fh (ev_io *w, SV *new_fh = 0) |
991 | SV *fh (ev_io *w, SV *new_fh = NO_INIT) |
976 | CODE: |
992 | CODE: |
977 | { |
993 | { |
978 | if (items > 1) |
994 | if (items > 1) |
979 | { |
995 | { |
980 | int fd = s_fileno (new_fh, w->events & EV_WRITE); |
996 | int fd = s_fileno (new_fh, w->events & EV_WRITE); |
… | |
… | |
989 | RETVAL = newSVsv (e_fh (w)); |
1005 | RETVAL = newSVsv (e_fh (w)); |
990 | } |
1006 | } |
991 | OUTPUT: |
1007 | OUTPUT: |
992 | RETVAL |
1008 | RETVAL |
993 | |
1009 | |
994 | int events (ev_io *w, int new_events = EV_UNDEF) |
1010 | int events (ev_io *w, int new_events = NO_INIT) |
995 | CODE: |
1011 | CODE: |
996 | { |
1012 | { |
997 | RETVAL = w->events; |
1013 | RETVAL = w->events; |
998 | |
1014 | |
999 | if (items > 1) |
1015 | if (items > 1 && (new_events ^ w->events) & (EV_READ | EV_WRITE)) |
1000 | { |
1016 | { |
1001 | int active = ev_is_active (w); |
1017 | PAUSE (io); |
1002 | if (active) STOP (io, w); |
|
|
1003 | ev_io_modify (w, new_events); |
1018 | ev_io_modify (w, new_events); |
1004 | if (active) START (io, w); |
1019 | RESUME (io); |
1005 | } |
1020 | } |
1006 | } |
1021 | } |
1007 | OUTPUT: |
1022 | OUTPUT: |
1008 | RETVAL |
1023 | RETVAL |
1009 | |
1024 | |
… | |
… | |
1029 | CHECK_SIG (signal, signum); |
1044 | CHECK_SIG (signal, signum); |
1030 | |
1045 | |
1031 | RESET_SIGNAL (w, (w, signum)); |
1046 | RESET_SIGNAL (w, (w, signum)); |
1032 | } |
1047 | } |
1033 | |
1048 | |
1034 | int signal (ev_signal *w, SV *new_signal = 0) |
1049 | int signal (ev_signal *w, SV *new_signal = NO_INIT) |
1035 | CODE: |
1050 | CODE: |
1036 | { |
1051 | { |
1037 | RETVAL = w->signum; |
1052 | RETVAL = w->signum; |
1038 | |
1053 | |
1039 | if (items > 1) |
1054 | if (items > 1) |
1040 | { |
1055 | { |
1041 | Signal signum = s_signum (new_signal); |
1056 | Signal signum = s_signum (new_signal); |
1042 | CHECK_SIG (new_signal, signum); |
1057 | CHECK_SIG (new_signal, signum); |
1043 | |
|
|
1044 | RESET_SIGNAL (w, (w, signum)); |
1058 | RESET_SIGNAL (w, (w, signum)); |
1045 | } |
1059 | } |
1046 | } |
1060 | } |
1047 | OUTPUT: |
1061 | OUTPUT: |
1048 | RETVAL |
1062 | RETVAL |
… | |
… | |
1059 | CODE: |
1073 | CODE: |
1060 | STOP (timer, w); |
1074 | STOP (timer, w); |
1061 | |
1075 | |
1062 | void ev_timer_again (ev_timer *w, NV repeat = NO_INIT) |
1076 | void ev_timer_again (ev_timer *w, NV repeat = NO_INIT) |
1063 | CODE: |
1077 | CODE: |
|
|
1078 | { |
1064 | if (items > 1) |
1079 | if (items > 1) |
|
|
1080 | { |
|
|
1081 | CHECK_REPEAT (repeat); |
1065 | w->repeat = repeat; |
1082 | w->repeat = repeat; |
1066 | CHECK_REPEAT (w->repeat); |
1083 | } |
|
|
1084 | |
1067 | ev_timer_again (e_loop (w), w); |
1085 | ev_timer_again (e_loop (w), w); |
1068 | UNREF (w); |
1086 | UNREF (w); |
|
|
1087 | } |
1069 | |
1088 | |
1070 | NV ev_timer_remaining (ev_timer *w) |
1089 | NV ev_timer_remaining (ev_timer *w) |
1071 | C_ARGS: e_loop (w), w |
1090 | C_ARGS: e_loop (w), w |
1072 | |
1091 | |
1073 | void DESTROY (ev_timer *w) |
1092 | void DESTROY (ev_timer *w) |
… | |
… | |
1079 | INIT: |
1098 | INIT: |
1080 | CHECK_REPEAT (repeat); |
1099 | CHECK_REPEAT (repeat); |
1081 | CODE: |
1100 | CODE: |
1082 | RESET (timer, w, (w, after, repeat)); |
1101 | RESET (timer, w, (w, after, repeat)); |
1083 | |
1102 | |
|
|
1103 | NV 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 | |
1084 | MODULE = EV PACKAGE = EV::Periodic PREFIX = ev_periodic_ |
1115 | MODULE = EV PACKAGE = EV::Periodic PREFIX = ev_periodic_ |
1085 | |
1116 | |
1086 | void ev_periodic_start (ev_periodic *w) |
1117 | void ev_periodic_start (ev_periodic *w) |
1087 | INIT: |
1118 | INIT: |
1088 | CHECK_REPEAT (w->interval); |
1119 | CHECK_REPEAT (w->interval); |
… | |
… | |
1118 | CODE: |
1149 | CODE: |
1119 | RETVAL = ev_periodic_at (w); |
1150 | RETVAL = ev_periodic_at (w); |
1120 | OUTPUT: |
1151 | OUTPUT: |
1121 | RETVAL |
1152 | RETVAL |
1122 | |
1153 | |
|
|
1154 | NV 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 | |
|
|
1162 | NV 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 | |
|
|
1174 | SV *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 | |
1123 | MODULE = EV PACKAGE = EV::Idle PREFIX = ev_idle_ |
1185 | MODULE = EV PACKAGE = EV::Idle PREFIX = ev_idle_ |
1124 | |
1186 | |
1125 | void ev_idle_start (ev_idle *w) |
1187 | void ev_idle_start (ev_idle *w) |
1126 | CODE: |
1188 | CODE: |
1127 | START (idle, w); |
1189 | START (idle, w); |
… | |
… | |
1208 | |
1270 | |
1209 | MODULE = EV PACKAGE = EV::Child PREFIX = ev_child_ |
1271 | MODULE = EV PACKAGE = EV::Child PREFIX = ev_child_ |
1210 | |
1272 | |
1211 | #if EV_CHILD_ENABLE |
1273 | #if EV_CHILD_ENABLE |
1212 | |
1274 | |
|
|
1275 | void ev_child_reinit () |
|
|
1276 | CODE: |
|
|
1277 | ev_signal_stop (evapi.default_loop, &childev); |
|
|
1278 | ev_signal_start (evapi.default_loop, &childev); |
|
|
1279 | |
1213 | void ev_child_start (ev_child *w) |
1280 | void ev_child_start (ev_child *w) |
1214 | CODE: |
1281 | CODE: |
1215 | START (child, w); |
1282 | START (child, w); |
1216 | |
1283 | |
1217 | void ev_child_stop (ev_child *w) |
1284 | void ev_child_stop (ev_child *w) |
… | |
… | |
1260 | { |
1327 | { |
1261 | sv_setsv (e_fh (w), path); |
1328 | sv_setsv (e_fh (w), path); |
1262 | RESET (stat, w, (w, SvPVbyte_nolen (e_fh (w)), interval)); |
1329 | RESET (stat, w, (w, SvPVbyte_nolen (e_fh (w)), interval)); |
1263 | } |
1330 | } |
1264 | |
1331 | |
1265 | SV *path (ev_stat *w, SV *new_path = 0) |
1332 | SV *path (ev_stat *w, SV *new_path = NO_INIT) |
1266 | CODE: |
1333 | CODE: |
1267 | { |
1334 | { |
1268 | RETVAL = SvREFCNT_inc (e_fh (w)); |
1335 | RETVAL = e_fh (w) ? newSVsv (e_fh (w)) : &PL_sv_undef; |
1269 | |
1336 | |
1270 | if (items > 1) |
1337 | if (items > 1) |
1271 | { |
1338 | { |
1272 | SvREFCNT_dec (e_fh (w)); |
1339 | sv_2mortal (e_fh (w)); |
1273 | e_fh (w) = newSVsv (new_path); |
1340 | e_fh (w) = newSVsv (new_path); |
1274 | RESET (stat, w, (w, SvPVbyte_nolen (e_fh (w)), w->interval)); |
1341 | RESET (stat, w, (w, SvPVbyte_nolen (e_fh (w)), w->interval)); |
1275 | } |
1342 | } |
1276 | } |
1343 | } |
1277 | OUTPUT: |
1344 | OUTPUT: |
1278 | RETVAL |
1345 | RETVAL |
1279 | |
1346 | |
1280 | NV interval (ev_stat *w, NV new_interval = 0.) |
1347 | NV interval (ev_stat *w, SV *new_interval = NO_INIT) |
1281 | CODE: |
1348 | CODE: |
1282 | { |
|
|
1283 | RETVAL = w->interval; |
1349 | RETVAL = w->interval; |
1284 | |
|
|
1285 | if (items > 1) |
1350 | if (items > 1) |
1286 | RESET (stat, w, (w, SvPVbyte_nolen (e_fh (w)), new_interval)); |
1351 | { |
1287 | } |
1352 | PAUSE (stat); |
|
|
1353 | w->interval = SvNV (new_interval); |
|
|
1354 | RESUME (stat); |
|
|
1355 | } |
1288 | OUTPUT: |
1356 | OUTPUT: |
1289 | RETVAL |
1357 | RETVAL |
1290 | |
1358 | |
1291 | void prev (ev_stat *w) |
1359 | void prev (ev_stat *w) |
1292 | ALIAS: |
1360 | ALIAS: |