… | |
… | |
50 | READ = EV_READ, |
50 | READ = EV_READ, |
51 | WRITE = EV_WRITE, |
51 | WRITE = EV_WRITE, |
52 | TIMEOUT = EV_TIMEOUT, |
52 | TIMEOUT = EV_TIMEOUT, |
53 | PERIODIC = EV_PERIODIC, |
53 | PERIODIC = EV_PERIODIC, |
54 | SIGNAL = EV_SIGNAL, |
54 | SIGNAL = EV_SIGNAL, |
|
|
55 | CHILD = EV_CHILD, |
|
|
56 | STAT = EV_STAT, |
55 | IDLE = EV_IDLE, |
57 | IDLE = EV_IDLE, |
56 | CHECK = EV_CHECK, |
58 | CHECK = EV_CHECK, |
57 | PREPARE = EV_PREPARE, |
59 | PREPARE = EV_PREPARE, |
58 | CHILD = EV_CHILD, |
60 | FORK = EV_FORK, |
|
|
61 | EMBED = EV_EMBED, |
59 | ERROR = EV_ERROR, |
62 | ERROR = EV_ERROR, |
60 | }; |
63 | }; |
61 | |
64 | |
62 | typedef ev_tstamp tstamp; |
65 | typedef ev_tstamp tstamp; |
63 | |
66 | |
… | |
… | |
191 | { |
194 | { |
192 | ev_timer_again (EV_A_ static_cast<ev_timer *>(this)); |
195 | ev_timer_again (EV_A_ static_cast<ev_timer *>(this)); |
193 | } |
196 | } |
194 | EV_END_WATCHER (timer, timer) |
197 | EV_END_WATCHER (timer, timer) |
195 | |
198 | |
196 | #if EV_PERIODICS |
199 | #if EV_PERIODIC_ENABLE |
197 | EV_BEGIN_WATCHER (periodic, periodic) |
200 | EV_BEGIN_WATCHER (periodic, periodic) |
198 | void set (ev_tstamp at, ev_tstamp interval = 0.) |
201 | void set (ev_tstamp at, ev_tstamp interval = 0.) |
199 | { |
202 | { |
200 | int active = is_active (); |
203 | int active = is_active (); |
201 | if (active) stop (); |
204 | if (active) stop (); |
… | |
… | |
212 | void again () |
215 | void again () |
213 | { |
216 | { |
214 | ev_periodic_again (EV_A_ static_cast<ev_periodic *>(this)); |
217 | ev_periodic_again (EV_A_ static_cast<ev_periodic *>(this)); |
215 | } |
218 | } |
216 | EV_END_WATCHER (periodic, periodic) |
219 | EV_END_WATCHER (periodic, periodic) |
|
|
220 | #endif |
|
|
221 | |
|
|
222 | EV_BEGIN_WATCHER (sig, signal) |
|
|
223 | void set (int signum) |
|
|
224 | { |
|
|
225 | int active = is_active (); |
|
|
226 | if (active) stop (); |
|
|
227 | ev_signal_set (static_cast<ev_signal *>(this), signum); |
|
|
228 | if (active) start (); |
|
|
229 | } |
|
|
230 | |
|
|
231 | void start (int signum) |
|
|
232 | { |
|
|
233 | set (signum); |
|
|
234 | start (); |
|
|
235 | } |
|
|
236 | EV_END_WATCHER (sig, signal) |
|
|
237 | |
|
|
238 | EV_BEGIN_WATCHER (child, child) |
|
|
239 | void set (int pid) |
|
|
240 | { |
|
|
241 | int active = is_active (); |
|
|
242 | if (active) stop (); |
|
|
243 | ev_child_set (static_cast<ev_child *>(this), pid); |
|
|
244 | if (active) start (); |
|
|
245 | } |
|
|
246 | |
|
|
247 | void start (int pid) |
|
|
248 | { |
|
|
249 | set (pid); |
|
|
250 | start (); |
|
|
251 | } |
|
|
252 | EV_END_WATCHER (child, child) |
|
|
253 | |
|
|
254 | #if EV_STAT_ENABLE |
|
|
255 | EV_BEGIN_WATCHER (stat, stat) |
|
|
256 | void set (const char *path, ev_tstamp interval = 0.) |
|
|
257 | { |
|
|
258 | int active = is_active (); |
|
|
259 | if (active) stop (); |
|
|
260 | ev_stat_set (static_cast<ev_stat *>(this), path, interval); |
|
|
261 | if (active) start (); |
|
|
262 | } |
|
|
263 | |
|
|
264 | void start (const char *path, ev_tstamp interval = 0.) |
|
|
265 | { |
|
|
266 | set (path, interval); |
|
|
267 | start (); |
|
|
268 | } |
|
|
269 | |
|
|
270 | void update () |
|
|
271 | { |
|
|
272 | ev_stat_stat (EV_A_ static_cast<ev_stat *>(this)); |
|
|
273 | } |
|
|
274 | EV_END_WATCHER (stat, stat) |
217 | #endif |
275 | #endif |
218 | |
276 | |
219 | EV_BEGIN_WATCHER (idle, idle) |
277 | EV_BEGIN_WATCHER (idle, idle) |
220 | void set () { } |
278 | void set () { } |
221 | EV_END_WATCHER (idle, idle) |
279 | EV_END_WATCHER (idle, idle) |
… | |
… | |
226 | |
284 | |
227 | EV_BEGIN_WATCHER (check, check) |
285 | EV_BEGIN_WATCHER (check, check) |
228 | void set () { } |
286 | void set () { } |
229 | EV_END_WATCHER (check, check) |
287 | EV_END_WATCHER (check, check) |
230 | |
288 | |
231 | EV_BEGIN_WATCHER (sig, signal) |
289 | #if EV_EMBED_ENABLE |
232 | void set (int signum) |
|
|
233 | { |
|
|
234 | int active = is_active (); |
|
|
235 | if (active) stop (); |
|
|
236 | ev_signal_set (static_cast<ev_signal *>(this), signum); |
|
|
237 | if (active) start (); |
|
|
238 | } |
|
|
239 | |
|
|
240 | void start (int signum) |
|
|
241 | { |
|
|
242 | set (signum); |
|
|
243 | start (); |
|
|
244 | } |
|
|
245 | EV_END_WATCHER (sig, signal) |
|
|
246 | |
|
|
247 | EV_BEGIN_WATCHER (child, child) |
|
|
248 | void set (int pid) |
|
|
249 | { |
|
|
250 | int active = is_active (); |
|
|
251 | if (active) stop (); |
|
|
252 | ev_child_set (static_cast<ev_child *>(this), pid); |
|
|
253 | if (active) start (); |
|
|
254 | } |
|
|
255 | |
|
|
256 | void start (int pid) |
|
|
257 | { |
|
|
258 | set (pid); |
|
|
259 | start (); |
|
|
260 | } |
|
|
261 | EV_END_WATCHER (child, child) |
|
|
262 | |
|
|
263 | #if EV_MULTIPLICITY |
|
|
264 | |
|
|
265 | EV_BEGIN_WATCHER (embed, embed) |
290 | EV_BEGIN_WATCHER (embed, embed) |
266 | void set (struct ev_loop *loop) |
291 | void set (struct ev_loop *loop) |
267 | { |
292 | { |
268 | int active = is_active (); |
293 | int active = is_active (); |
269 | if (active) stop (); |
294 | if (active) stop (); |
… | |
… | |
280 | void sweep () |
305 | void sweep () |
281 | { |
306 | { |
282 | ev_embed_sweep (EV_A_ static_cast<ev_embed *>(this)); |
307 | ev_embed_sweep (EV_A_ static_cast<ev_embed *>(this)); |
283 | } |
308 | } |
284 | EV_END_WATCHER (embed, embed) |
309 | EV_END_WATCHER (embed, embed) |
|
|
310 | #endif |
285 | |
311 | |
|
|
312 | #if EV_FORK_ENABLE |
|
|
313 | EV_BEGIN_WATCHER (fork, fork) |
|
|
314 | void set () { } |
|
|
315 | EV_END_WATCHER (fork, fork) |
286 | #endif |
316 | #endif |
287 | |
317 | |
288 | #undef EV_CONSTRUCT |
318 | #undef EV_CONSTRUCT |
289 | #undef EV_BEGIN_WATCHER |
319 | #undef EV_BEGIN_WATCHER |
290 | #undef EV_END_WATCHER |
320 | #undef EV_END_WATCHER |