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