1 | /* |
1 | /* |
2 | * libev simple C++ wrapper classes |
2 | * libev simple C++ wrapper classes |
3 | * |
3 | * |
4 | * Copyright (c) 2007 Marc Alexander Lehmann <libev@schmorp.de> |
4 | * Copyright (c) 2007,2008,2010 Marc Alexander Lehmann <libev@schmorp.de> |
5 | * All rights reserved. |
5 | * All rights reserved. |
6 | * |
6 | * |
7 | * Redistribution and use in source and binary forms, with or without modifica- |
7 | * Redistribution and use in source and binary forms, with or without modifica- |
8 | * tion, are permitted provided that the following conditions are met: |
8 | * tion, are permitted provided that the following conditions are met: |
9 | * |
9 | * |
… | |
… | |
56 | |
56 | |
57 | namespace ev { |
57 | namespace ev { |
58 | |
58 | |
59 | typedef ev_tstamp tstamp; |
59 | typedef ev_tstamp tstamp; |
60 | |
60 | |
61 | enum { |
61 | enum |
|
|
62 | { |
62 | UNDEF = EV_UNDEF, |
63 | UNDEF = EV_UNDEF, |
63 | NONE = EV_NONE, |
64 | NONE = EV_NONE, |
64 | READ = EV_READ, |
65 | READ = EV_READ, |
65 | WRITE = EV_WRITE, |
66 | WRITE = EV_WRITE, |
|
|
67 | #if EV_COMPAT3 |
66 | TIMEOUT = EV_TIMEOUT, |
68 | TIMEOUT = EV_TIMEOUT, |
|
|
69 | #endif |
|
|
70 | TIMER = EV_TIMER, |
67 | PERIODIC = EV_PERIODIC, |
71 | PERIODIC = EV_PERIODIC, |
68 | SIGNAL = EV_SIGNAL, |
72 | SIGNAL = EV_SIGNAL, |
69 | CHILD = EV_CHILD, |
73 | CHILD = EV_CHILD, |
70 | STAT = EV_STAT, |
74 | STAT = EV_STAT, |
71 | IDLE = EV_IDLE, |
75 | IDLE = EV_IDLE, |
72 | CHECK = EV_CHECK, |
76 | CHECK = EV_CHECK, |
73 | PREPARE = EV_PREPARE, |
77 | PREPARE = EV_PREPARE, |
74 | FORK = EV_FORK, |
78 | FORK = EV_FORK, |
75 | ASYNC = EV_ASYNC, |
79 | ASYNC = EV_ASYNC, |
76 | EMBED = EV_EMBED, |
80 | EMBED = EV_EMBED, |
|
|
81 | # undef ERROR // some systems stupidly #define ERROR |
77 | ERROR = EV_ERROR, |
82 | ERROR = EV_ERROR |
78 | }; |
83 | }; |
79 | |
84 | |
80 | enum |
85 | enum |
81 | { |
86 | { |
82 | AUTO = EVFLAG_AUTO, |
87 | AUTO = EVFLAG_AUTO, |
83 | NOENV = EVFLAG_NOENV, |
88 | NOENV = EVFLAG_NOENV, |
84 | FORKCHECK = EVFLAG_FORKCHECK, |
89 | FORKCHECK = EVFLAG_FORKCHECK, |
|
|
90 | |
85 | SELECT = EVBACKEND_SELECT, |
91 | SELECT = EVBACKEND_SELECT, |
86 | POLL = EVBACKEND_POLL, |
92 | POLL = EVBACKEND_POLL, |
87 | EPOLL = EVBACKEND_EPOLL, |
93 | EPOLL = EVBACKEND_EPOLL, |
88 | KQUEUE = EVBACKEND_KQUEUE, |
94 | KQUEUE = EVBACKEND_KQUEUE, |
89 | DEVPOLL = EVBACKEND_DEVPOLL, |
95 | DEVPOLL = EVBACKEND_DEVPOLL, |
90 | PORT = EVBACKEND_PORT |
96 | PORT = EVBACKEND_PORT |
91 | }; |
97 | }; |
92 | |
98 | |
93 | enum |
99 | enum |
94 | { |
100 | { |
|
|
101 | #if EV_COMPAT3 |
95 | NONBLOCK = EVLOOP_NONBLOCK, |
102 | NONBLOCK = EVLOOP_NONBLOCK, |
96 | ONESHOT = EVLOOP_ONESHOT |
103 | ONESHOT = EVLOOP_ONESHOT, |
|
|
104 | #endif |
|
|
105 | NOWAIT = EVRUN_NOWAIT, |
|
|
106 | ONCE = EVRUN_ONCE |
97 | }; |
107 | }; |
98 | |
108 | |
99 | enum how_t |
109 | enum how_t |
100 | { |
110 | { |
101 | ONE = EVUNLOOP_ONE, |
111 | ONE = EVBREAK_ONE, |
102 | ALL = EVUNLOOP_ALL |
112 | ALL = EVBREAK_ALL |
103 | }; |
113 | }; |
104 | |
114 | |
105 | struct bad_loop |
115 | struct bad_loop |
106 | #if EV_USE_STDEXCEPT |
116 | #if EV_USE_STDEXCEPT |
107 | : std::runtime_error |
117 | : std::runtime_error |
… | |
… | |
157 | return false; |
167 | return false; |
158 | #endif |
168 | #endif |
159 | } |
169 | } |
160 | |
170 | |
161 | #if EV_MULTIPLICITY |
171 | #if EV_MULTIPLICITY |
162 | bool operator == (struct ev_loop *other) const throw () |
172 | bool operator == (const EV_P) const throw () |
163 | { |
173 | { |
164 | return this->EV_AX == other; |
174 | return this->EV_AX == EV_A; |
165 | } |
|
|
166 | |
|
|
167 | bool operator != (struct ev_loop *other) const throw () |
|
|
168 | { |
175 | } |
169 | return ! (*this == other); |
176 | |
|
|
177 | bool operator != (const EV_P) const throw () |
170 | } |
178 | { |
171 | |
|
|
172 | bool operator == (const struct ev_loop *other) const throw () |
|
|
173 | { |
|
|
174 | return this->EV_AX == other; |
|
|
175 | } |
|
|
176 | |
|
|
177 | bool operator != (const struct ev_loop *other) const throw () |
|
|
178 | { |
|
|
179 | return (*this == other); |
179 | return (*this == EV_A); |
180 | } |
180 | } |
181 | |
181 | |
182 | operator struct ev_loop * () const throw () |
182 | operator struct ev_loop * () const throw () |
183 | { |
183 | { |
184 | return EV_AX; |
184 | return EV_AX; |
… | |
… | |
193 | { |
193 | { |
194 | return EV_AX == ev_default_loop (0); |
194 | return EV_AX == ev_default_loop (0); |
195 | } |
195 | } |
196 | #endif |
196 | #endif |
197 | |
197 | |
|
|
198 | #if EV_COMPAT3 |
198 | void loop (int flags = 0) |
199 | void loop (int flags = 0) |
199 | { |
200 | { |
200 | ev_loop (EV_AX_ flags); |
201 | ev_run (EV_AX_ flags); |
201 | } |
202 | } |
202 | |
203 | |
203 | void unloop (how_t how = ONE) throw () |
204 | void unloop (how_t how = ONE) throw () |
204 | { |
205 | { |
205 | ev_unloop (EV_AX_ how); |
206 | ev_break (EV_AX_ how); |
|
|
207 | } |
|
|
208 | #endif |
|
|
209 | |
|
|
210 | void run (int flags = 0) |
|
|
211 | { |
|
|
212 | ev_run (EV_AX_ flags); |
|
|
213 | } |
|
|
214 | |
|
|
215 | void break_loop (how_t how = ONE) throw () |
|
|
216 | { |
|
|
217 | ev_break (EV_AX_ how); |
206 | } |
218 | } |
207 | |
219 | |
208 | void post_fork () throw () |
220 | void post_fork () throw () |
209 | { |
221 | { |
210 | #if EV_MULTIPLICITY |
|
|
211 | ev_loop_fork (EV_AX); |
222 | ev_loop_fork (EV_AX); |
212 | #else |
|
|
213 | ev_default_fork (); |
|
|
214 | #endif |
|
|
215 | } |
|
|
216 | |
|
|
217 | unsigned int count () const throw () |
|
|
218 | { |
|
|
219 | return ev_loop_count (EV_AX); |
|
|
220 | } |
223 | } |
221 | |
224 | |
222 | unsigned int backend () const throw () |
225 | unsigned int backend () const throw () |
223 | { |
226 | { |
224 | return ev_backend (EV_AX); |
227 | return ev_backend (EV_AX); |
… | |
… | |
237 | void unref () throw () |
240 | void unref () throw () |
238 | { |
241 | { |
239 | ev_unref (EV_AX); |
242 | ev_unref (EV_AX); |
240 | } |
243 | } |
241 | |
244 | |
|
|
245 | #if EV_FEATURE_API |
|
|
246 | unsigned int iteration () const throw () |
|
|
247 | { |
|
|
248 | return ev_iteration (EV_AX); |
|
|
249 | } |
|
|
250 | |
|
|
251 | unsigned int depth () const throw () |
|
|
252 | { |
|
|
253 | return ev_depth (EV_AX); |
|
|
254 | } |
|
|
255 | |
242 | void set_io_collect_interval (tstamp interval) throw () |
256 | void set_io_collect_interval (tstamp interval) throw () |
243 | { |
257 | { |
244 | ev_set_io_collect_interval (EV_AX_ interval); |
258 | ev_set_io_collect_interval (EV_AX_ interval); |
245 | } |
259 | } |
246 | |
260 | |
247 | void set_timeout_collect_interval (tstamp interval) throw () |
261 | void set_timeout_collect_interval (tstamp interval) throw () |
248 | { |
262 | { |
249 | ev_set_timeout_collect_interval (EV_AX_ interval); |
263 | ev_set_timeout_collect_interval (EV_AX_ interval); |
250 | } |
264 | } |
|
|
265 | #endif |
251 | |
266 | |
252 | // function callback |
267 | // function callback |
253 | void once (int fd, int events, tstamp timeout, void (*cb)(int, void *), void* arg = 0) throw () |
268 | void once (int fd, int events, tstamp timeout, void (*cb)(int, void *), void *arg = 0) throw () |
254 | { |
269 | { |
255 | ev_once (EV_AX_ fd, events, timeout, cb, arg); |
270 | ev_once (EV_AX_ fd, events, timeout, cb, arg); |
256 | } |
271 | } |
257 | |
272 | |
258 | // method callback |
273 | // method callback |
… | |
… | |
260 | void once (int fd, int events, tstamp timeout, K *object) throw () |
275 | void once (int fd, int events, tstamp timeout, K *object) throw () |
261 | { |
276 | { |
262 | once (fd, events, timeout, method_thunk<K, method>, object); |
277 | once (fd, events, timeout, method_thunk<K, method>, object); |
263 | } |
278 | } |
264 | |
279 | |
|
|
280 | // default method == operator () |
|
|
281 | template<class K> |
|
|
282 | void once (int fd, int events, tstamp timeout, K *object) throw () |
|
|
283 | { |
|
|
284 | once (fd, events, timeout, method_thunk<K, &K::operator ()>, object); |
|
|
285 | } |
|
|
286 | |
265 | template<class K, void (K::*method)(int)> |
287 | template<class K, void (K::*method)(int)> |
266 | static void method_thunk (int revents, void* arg) |
288 | static void method_thunk (int revents, void *arg) |
267 | { |
|
|
268 | K *obj = static_cast<K *>(arg); |
|
|
269 | (obj->*method) (revents); |
|
|
270 | } |
289 | { |
|
|
290 | static_cast<K *>(arg)->*method |
|
|
291 | (revents); |
|
|
292 | } |
271 | |
293 | |
272 | // const method callback |
294 | // no-argument method callback |
273 | template<class K, void (K::*method)(int) const> |
|
|
274 | void once (int fd, int events, tstamp timeout, const K *object) throw () |
|
|
275 | { |
|
|
276 | once (fd, events, timeout, const_method_thunk<K, method>, object); |
|
|
277 | } |
|
|
278 | |
|
|
279 | template<class K, void (K::*method)(int) const> |
|
|
280 | static void const_method_thunk (int revents, void* arg) |
|
|
281 | { |
|
|
282 | K *obj = static_cast<K *>(arg); |
|
|
283 | (obj->*method) (revents); |
|
|
284 | } |
|
|
285 | |
|
|
286 | // simple method callback |
|
|
287 | template<class K, void (K::*method)()> |
295 | template<class K, void (K::*method)()> |
288 | void once (int fd, int events, tstamp timeout, K *object) throw () |
296 | void once (int fd, int events, tstamp timeout, K *object) throw () |
289 | { |
297 | { |
290 | once (fd, events, timeout, method_noargs_thunk<K, method>, object); |
298 | once (fd, events, timeout, method_noargs_thunk<K, method>, object); |
291 | } |
299 | } |
292 | |
300 | |
293 | template<class K, void (K::*method)()> |
301 | template<class K, void (K::*method)()> |
294 | static void method_noargs_thunk (int revents, void* arg) |
302 | static void method_noargs_thunk (int revents, void *arg) |
295 | { |
303 | { |
296 | K *obj = static_cast<K *>(arg); |
304 | static_cast<K *>(arg)->*method |
297 | (obj->*method) (); |
305 | (); |
298 | } |
306 | } |
299 | |
307 | |
300 | // simpler function callback |
308 | // simpler function callback |
301 | template<void (*cb)(int)> |
309 | template<void (*cb)(int)> |
302 | void once (int fd, int events, tstamp timeout) throw () |
310 | void once (int fd, int events, tstamp timeout) throw () |
303 | { |
311 | { |
304 | once (fd, events, timeout, simpler_func_thunk<cb>); |
312 | once (fd, events, timeout, simpler_func_thunk<cb>); |
305 | } |
313 | } |
306 | |
314 | |
307 | template<void (*cb)(int)> |
315 | template<void (*cb)(int)> |
308 | static void simpler_func_thunk (int revents, void* arg) |
316 | static void simpler_func_thunk (int revents, void *arg) |
309 | { |
317 | { |
|
|
318 | (*cb) |
310 | (*cb) (revents); |
319 | (revents); |
311 | } |
320 | } |
312 | |
321 | |
313 | // simplest function callback |
322 | // simplest function callback |
314 | template<void (*cb)()> |
323 | template<void (*cb)()> |
315 | void once (int fd, int events, tstamp timeout) throw () |
324 | void once (int fd, int events, tstamp timeout) throw () |
316 | { |
325 | { |
317 | once (fd, events, timeout, simplest_func_thunk<cb>); |
326 | once (fd, events, timeout, simplest_func_thunk<cb>); |
318 | } |
327 | } |
319 | |
328 | |
320 | template<void (*cb)()> |
329 | template<void (*cb)()> |
321 | static void simplest_func_thunk (int revents, void* arg) |
330 | static void simplest_func_thunk (int revents, void *arg) |
322 | { |
331 | { |
323 | (*cb) (); |
332 | (*cb) |
|
|
333 | (); |
324 | } |
334 | } |
325 | |
335 | |
326 | void feed_fd_event (int fd, int revents) throw () |
336 | void feed_fd_event (int fd, int revents) throw () |
327 | { |
337 | { |
328 | ev_feed_fd_event (EV_AX_ fd, revents); |
338 | ev_feed_fd_event (EV_AX_ fd, revents); |
… | |
… | |
378 | #else |
388 | #else |
379 | !ev_default_loop (flags) |
389 | !ev_default_loop (flags) |
380 | #endif |
390 | #endif |
381 | ) |
391 | ) |
382 | throw bad_loop (); |
392 | throw bad_loop (); |
383 | } |
|
|
384 | |
|
|
385 | ~default_loop () throw () |
|
|
386 | { |
|
|
387 | ev_default_destroy (); |
|
|
388 | } |
393 | } |
389 | |
394 | |
390 | private: |
395 | private: |
391 | default_loop (const default_loop &); |
396 | default_loop (const default_loop &); |
392 | default_loop &operator = (const default_loop &); |
397 | default_loop &operator = (const default_loop &); |
… | |
… | |
418 | struct base : ev_watcher |
423 | struct base : ev_watcher |
419 | { |
424 | { |
420 | #if EV_MULTIPLICITY |
425 | #if EV_MULTIPLICITY |
421 | EV_PX; |
426 | EV_PX; |
422 | |
427 | |
|
|
428 | // loop set |
423 | void set (EV_PX) throw () |
429 | void set (EV_P) throw () |
424 | { |
430 | { |
425 | this->EV_A = EV_A; |
431 | this->EV_A = EV_A; |
426 | } |
432 | } |
427 | #endif |
433 | #endif |
428 | |
434 | |
… | |
… | |
432 | #endif |
438 | #endif |
433 | { |
439 | { |
434 | ev_init (this, 0); |
440 | ev_init (this, 0); |
435 | } |
441 | } |
436 | |
442 | |
437 | void set_ (void *data, void (*cb)(EV_P_ ev_watcher *w, int revents)) throw () |
443 | void set_ (const void *data, void (*cb)(EV_P_ ev_watcher *w, int revents)) throw () |
438 | { |
444 | { |
439 | this->data = data; |
445 | this->data = (void *)data; |
440 | ev_set_cb (static_cast<ev_watcher *>(this), cb); |
446 | ev_set_cb (static_cast<ev_watcher *>(this), cb); |
|
|
447 | } |
|
|
448 | |
|
|
449 | // function callback |
|
|
450 | template<void (*function)(watcher &w, int)> |
|
|
451 | void set (void *data = 0) throw () |
|
|
452 | { |
|
|
453 | set_ (data, function_thunk<function>); |
|
|
454 | } |
|
|
455 | |
|
|
456 | template<void (*function)(watcher &w, int)> |
|
|
457 | static void function_thunk (EV_P_ ev_watcher *w, int revents) |
|
|
458 | { |
|
|
459 | function |
|
|
460 | (*static_cast<watcher *>(w), revents); |
441 | } |
461 | } |
442 | |
462 | |
443 | // method callback |
463 | // method callback |
444 | template<class K, void (K::*method)(watcher &w, int)> |
464 | template<class K, void (K::*method)(watcher &w, int)> |
445 | void set (K *object) throw () |
465 | void set (K *object) throw () |
446 | { |
466 | { |
447 | set_ (object, method_thunk<K, method>); |
467 | set_ (object, method_thunk<K, method>); |
448 | } |
468 | } |
449 | |
469 | |
|
|
470 | // default method == operator () |
|
|
471 | template<class K> |
|
|
472 | void set (K *object) throw () |
|
|
473 | { |
|
|
474 | set_ (object, method_thunk<K, &K::operator ()>); |
|
|
475 | } |
|
|
476 | |
450 | template<class K, void (K::*method)(watcher &w, int)> |
477 | template<class K, void (K::*method)(watcher &w, int)> |
451 | static void method_thunk (EV_P_ ev_watcher *w, int revents) |
478 | static void method_thunk (EV_P_ ev_watcher *w, int revents) |
452 | { |
479 | { |
453 | K *obj = static_cast<K *>(w->data); |
480 | (static_cast<K *>(w->data)->*method) |
454 | (obj->*method) (*static_cast<watcher *>(w), revents); |
|
|
455 | } |
|
|
456 | |
|
|
457 | // const method callback |
|
|
458 | template<class K, void (K::*method)(watcher &w, int) const> |
|
|
459 | void set (const K *object) throw () |
|
|
460 | { |
|
|
461 | set_ (object, const_method_thunk<K, method>); |
|
|
462 | } |
|
|
463 | |
|
|
464 | template<class K, void (K::*method)(watcher &w, int) const> |
|
|
465 | static void const_method_thunk (EV_P_ ev_watcher *w, int revents) |
|
|
466 | { |
|
|
467 | K *obj = static_cast<K *>(w->data); |
|
|
468 | (static_cast<K *>(w->data)->*method) (*static_cast<watcher *>(w), revents); |
|
|
469 | } |
|
|
470 | |
|
|
471 | // function callback |
|
|
472 | template<void (*function)(watcher &w, int)> |
|
|
473 | void set (void *data = 0) throw () |
|
|
474 | { |
|
|
475 | set_ (data, function_thunk<function>); |
|
|
476 | } |
|
|
477 | |
|
|
478 | template<void (*function)(watcher &w, int)> |
|
|
479 | static void function_thunk (EV_P_ ev_watcher *w, int revents) |
|
|
480 | { |
|
|
481 | function (*static_cast<watcher *>(w), revents); |
481 | (*static_cast<watcher *>(w), revents); |
482 | } |
482 | } |
483 | |
483 | |
484 | // simple callback |
484 | // no-argument callback |
485 | template<class K, void (K::*method)()> |
485 | template<class K, void (K::*method)()> |
486 | void set (K *object) throw () |
486 | void set (K *object) throw () |
487 | { |
487 | { |
488 | set_ (object, method_noargs_thunk<K, method>); |
488 | set_ (object, method_noargs_thunk<K, method>); |
489 | } |
489 | } |
490 | |
490 | |
491 | template<class K, void (K::*method)()> |
491 | template<class K, void (K::*method)()> |
492 | static void method_noargs_thunk (EV_P_ ev_watcher *w, int revents) |
492 | static void method_noargs_thunk (EV_P_ ev_watcher *w, int revents) |
493 | { |
493 | { |
494 | K *obj = static_cast<K *>(w->data); |
494 | (static_cast<K *>(w->data)->*method) |
495 | (obj->*method) (); |
495 | (); |
496 | } |
496 | } |
497 | |
497 | |
498 | void operator ()(int events = EV_UNDEF) |
498 | void operator ()(int events = EV_UNDEF) |
499 | { |
499 | { |
|
|
500 | return |
500 | return ev_cb (static_cast<ev_watcher *>(this)) |
501 | ev_cb (static_cast<ev_watcher *>(this)) |
501 | (static_cast<ev_watcher *>(this), events); |
502 | (static_cast<ev_watcher *>(this), events); |
502 | } |
503 | } |
503 | |
504 | |
504 | bool is_active () const throw () |
505 | bool is_active () const throw () |
505 | { |
506 | { |
506 | return ev_is_active (static_cast<const ev_watcher *>(this)); |
507 | return ev_is_active (static_cast<const ev_watcher *>(this)); |
… | |
… | |
652 | |
653 | |
653 | void again () throw () |
654 | void again () throw () |
654 | { |
655 | { |
655 | ev_timer_again (EV_A_ static_cast<ev_timer *>(this)); |
656 | ev_timer_again (EV_A_ static_cast<ev_timer *>(this)); |
656 | } |
657 | } |
|
|
658 | |
|
|
659 | ev_tstamp remaining () |
|
|
660 | { |
|
|
661 | return ev_timer_remaining (EV_A_ static_cast<ev_timer *>(this)); |
|
|
662 | } |
657 | EV_END_WATCHER (timer, timer) |
663 | EV_END_WATCHER (timer, timer) |
658 | |
664 | |
659 | #if EV_PERIODIC_ENABLE |
665 | #if EV_PERIODIC_ENABLE |
660 | EV_BEGIN_WATCHER (periodic, periodic) |
666 | EV_BEGIN_WATCHER (periodic, periodic) |
661 | void set (ev_tstamp at, ev_tstamp interval = 0.) throw () |
667 | void set (ev_tstamp at, ev_tstamp interval = 0.) throw () |
… | |
… | |
677 | ev_periodic_again (EV_A_ static_cast<ev_periodic *>(this)); |
683 | ev_periodic_again (EV_A_ static_cast<ev_periodic *>(this)); |
678 | } |
684 | } |
679 | EV_END_WATCHER (periodic, periodic) |
685 | EV_END_WATCHER (periodic, periodic) |
680 | #endif |
686 | #endif |
681 | |
687 | |
|
|
688 | #if EV_SIGNAL_ENABLE |
682 | EV_BEGIN_WATCHER (sig, signal) |
689 | EV_BEGIN_WATCHER (sig, signal) |
683 | void set (int signum) throw () |
690 | void set (int signum) throw () |
684 | { |
691 | { |
685 | int active = is_active (); |
692 | int active = is_active (); |
686 | if (active) stop (); |
693 | if (active) stop (); |
… | |
… | |
692 | { |
699 | { |
693 | set (signum); |
700 | set (signum); |
694 | start (); |
701 | start (); |
695 | } |
702 | } |
696 | EV_END_WATCHER (sig, signal) |
703 | EV_END_WATCHER (sig, signal) |
|
|
704 | #endif |
697 | |
705 | |
|
|
706 | #if EV_CHILD_ENABLE |
698 | EV_BEGIN_WATCHER (child, child) |
707 | EV_BEGIN_WATCHER (child, child) |
699 | void set (int pid, int trace = 0) throw () |
708 | void set (int pid, int trace = 0) throw () |
700 | { |
709 | { |
701 | int active = is_active (); |
710 | int active = is_active (); |
702 | if (active) stop (); |
711 | if (active) stop (); |
… | |
… | |
708 | { |
717 | { |
709 | set (pid, trace); |
718 | set (pid, trace); |
710 | start (); |
719 | start (); |
711 | } |
720 | } |
712 | EV_END_WATCHER (child, child) |
721 | EV_END_WATCHER (child, child) |
|
|
722 | #endif |
713 | |
723 | |
714 | #if EV_STAT_ENABLE |
724 | #if EV_STAT_ENABLE |
715 | EV_BEGIN_WATCHER (stat, stat) |
725 | EV_BEGIN_WATCHER (stat, stat) |
716 | void set (const char *path, ev_tstamp interval = 0.) throw () |
726 | void set (const char *path, ev_tstamp interval = 0.) throw () |
717 | { |
727 | { |
… | |
… | |
733 | ev_stat_stat (EV_A_ static_cast<ev_stat *>(this)); |
743 | ev_stat_stat (EV_A_ static_cast<ev_stat *>(this)); |
734 | } |
744 | } |
735 | EV_END_WATCHER (stat, stat) |
745 | EV_END_WATCHER (stat, stat) |
736 | #endif |
746 | #endif |
737 | |
747 | |
|
|
748 | #if EV_IDLE_ENABLE |
738 | EV_BEGIN_WATCHER (idle, idle) |
749 | EV_BEGIN_WATCHER (idle, idle) |
739 | void set () throw () { } |
750 | void set () throw () { } |
740 | EV_END_WATCHER (idle, idle) |
751 | EV_END_WATCHER (idle, idle) |
|
|
752 | #endif |
741 | |
753 | |
|
|
754 | #if EV_PREPARE_ENABLE |
742 | EV_BEGIN_WATCHER (prepare, prepare) |
755 | EV_BEGIN_WATCHER (prepare, prepare) |
743 | void set () throw () { } |
756 | void set () throw () { } |
744 | EV_END_WATCHER (prepare, prepare) |
757 | EV_END_WATCHER (prepare, prepare) |
|
|
758 | #endif |
745 | |
759 | |
|
|
760 | #if EV_CHECK_ENABLE |
746 | EV_BEGIN_WATCHER (check, check) |
761 | EV_BEGIN_WATCHER (check, check) |
747 | void set () throw () { } |
762 | void set () throw () { } |
748 | EV_END_WATCHER (check, check) |
763 | EV_END_WATCHER (check, check) |
|
|
764 | #endif |
749 | |
765 | |
750 | #if EV_EMBED_ENABLE |
766 | #if EV_EMBED_ENABLE |
751 | EV_BEGIN_WATCHER (embed, embed) |
767 | EV_BEGIN_WATCHER (embed, embed) |
752 | void set (struct ev_loop *embedded_loop) throw () |
768 | void set (struct ev_loop *embedded_loop) throw () |
753 | { |
769 | { |
… | |
… | |
776 | EV_END_WATCHER (fork, fork) |
792 | EV_END_WATCHER (fork, fork) |
777 | #endif |
793 | #endif |
778 | |
794 | |
779 | #if EV_ASYNC_ENABLE |
795 | #if EV_ASYNC_ENABLE |
780 | EV_BEGIN_WATCHER (async, async) |
796 | EV_BEGIN_WATCHER (async, async) |
781 | void set () throw () { } |
|
|
782 | |
|
|
783 | void send () throw () |
797 | void send () throw () |
784 | { |
798 | { |
785 | ev_async_send (EV_A_ static_cast<ev_async *>(this)); |
799 | ev_async_send (EV_A_ static_cast<ev_async *>(this)); |
786 | } |
800 | } |
787 | |
801 | |