… | |
… | |
104 | ONE = EVUNLOOP_ONE, |
104 | ONE = EVUNLOOP_ONE, |
105 | ALL = EVUNLOOP_ALL |
105 | ALL = EVUNLOOP_ALL |
106 | }; |
106 | }; |
107 | |
107 | |
108 | #if EV_CXX_EXCEPTIONS |
108 | #if EV_CXX_EXCEPTIONS |
109 | struct bad_loop: std::runtime_error |
109 | struct bad_loop : std::runtime_error |
110 | { |
110 | { |
111 | bad_loop() |
111 | bad_loop () |
112 | : std::runtime_error("loop can't be initialized") {} |
112 | : std::runtime_error ("loop can't be initialized") |
|
|
113 | { |
|
|
114 | } |
113 | }; |
115 | }; |
114 | #endif |
116 | #endif |
115 | |
117 | |
116 | #ifdef EV_AX |
118 | #ifdef EV_AX |
117 | # undef EV_AX |
119 | # undef EV_AX |
… | |
… | |
141 | if (!EV_A) |
143 | if (!EV_A) |
142 | throw bad_loop (); |
144 | throw bad_loop (); |
143 | #endif |
145 | #endif |
144 | } |
146 | } |
145 | |
147 | |
146 | bool operator== (const loop_ref &other) const EV_THROW () |
148 | bool operator== (const loop_ref &other) const throw () |
147 | { |
149 | { |
148 | #if EV_MULTIPLICITY |
150 | #if EV_MULTIPLICITY |
149 | return this->EV_AX == other.EV_AX; |
151 | return this->EV_AX == other.EV_AX; |
150 | #else |
152 | #else |
151 | return true; |
153 | return true; |
152 | #endif |
154 | #endif |
153 | } |
155 | } |
154 | |
156 | |
155 | bool operator!= (const loop_ref &other) const EV_THROW () |
157 | bool operator!= (const loop_ref &other) const throw () |
156 | { |
158 | { |
157 | #if EV_MULTIPLICITY |
159 | #if EV_MULTIPLICITY |
158 | return ! (*this == other); |
160 | return ! (*this == other); |
159 | #else |
161 | #else |
160 | return false; |
162 | return false; |
161 | #endif |
163 | #endif |
162 | } |
164 | } |
163 | |
165 | |
164 | #if EV_MULTIPLICITY |
166 | #if EV_MULTIPLICITY |
165 | bool operator== (struct ev_loop *other) const EV_THROW () |
167 | bool operator== (struct ev_loop *other) const throw () |
166 | { |
168 | { |
167 | return this->EV_AX == other; |
169 | return this->EV_AX == other; |
168 | } |
170 | } |
169 | |
171 | |
170 | bool operator!= (struct ev_loop *other) const EV_THROW () |
172 | bool operator!= (struct ev_loop *other) const throw () |
171 | { |
173 | { |
172 | return ! (*this == other); |
174 | return ! (*this == other); |
173 | } |
175 | } |
174 | |
176 | |
175 | bool operator== (const struct ev_loop *other) const EV_THROW () |
177 | bool operator== (const struct ev_loop *other) const throw () |
176 | { |
178 | { |
177 | return this->EV_AX == other; |
179 | return this->EV_AX == other; |
178 | } |
180 | } |
179 | |
181 | |
180 | bool operator!= (const struct ev_loop *other) const EV_THROW () |
182 | bool operator!= (const struct ev_loop *other) const throw () |
181 | { |
183 | { |
182 | return (*this == other); |
184 | return (*this == other); |
183 | } |
185 | } |
184 | |
186 | |
185 | operator struct ev_loop * () const EV_THROW () |
187 | operator struct ev_loop * () const throw () |
186 | { |
188 | { |
187 | return EV_AX; |
189 | return EV_AX; |
188 | } |
190 | } |
189 | |
191 | |
190 | operator const struct ev_loop * () const EV_THROW () |
192 | operator const struct ev_loop * () const throw () |
191 | { |
193 | { |
192 | return EV_AX; |
194 | return EV_AX; |
193 | } |
195 | } |
194 | |
196 | |
195 | bool is_default () const EV_THROW () |
197 | bool is_default () const throw () |
196 | { |
198 | { |
197 | return EV_AX == ev_default_loop (0); |
199 | return EV_AX == ev_default_loop (0); |
198 | } |
200 | } |
199 | #endif |
201 | #endif |
200 | |
202 | |
201 | void loop (int flags = 0) |
203 | void loop (int flags = 0) |
202 | { |
204 | { |
203 | ev_loop (EV_AX_ flags); |
205 | ev_loop (EV_AX_ flags); |
204 | } |
206 | } |
205 | |
207 | |
206 | void unloop (how_t how = ONE) EV_THROW () |
208 | void unloop (how_t how = ONE) throw () |
207 | { |
209 | { |
208 | ev_unloop (EV_AX_ how); |
210 | ev_unloop (EV_AX_ how); |
209 | } |
211 | } |
210 | |
212 | |
211 | void post_fork () EV_THROW () |
213 | void post_fork () throw () |
212 | { |
214 | { |
213 | #if EV_MULTIPLICITY |
215 | #if EV_MULTIPLICITY |
214 | ev_loop_fork (EV_AX); |
216 | ev_loop_fork (EV_AX); |
215 | #else |
217 | #else |
216 | ev_default_fork (); |
218 | ev_default_fork (); |
217 | #endif |
219 | #endif |
218 | } |
220 | } |
219 | |
221 | |
220 | unsigned int count () const EV_THROW () |
222 | unsigned int count () const throw () |
221 | { |
223 | { |
222 | return ev_loop_count (EV_AX); |
224 | return ev_loop_count (EV_AX); |
223 | } |
225 | } |
224 | |
226 | |
225 | unsigned int backend () const EV_THROW () |
227 | unsigned int backend () const throw () |
226 | { |
228 | { |
227 | return ev_backend (EV_AX); |
229 | return ev_backend (EV_AX); |
228 | } |
230 | } |
229 | |
231 | |
230 | tstamp now () const EV_THROW () |
232 | tstamp now () const throw () |
231 | { |
233 | { |
232 | return ev_now (EV_AX); |
234 | return ev_now (EV_AX); |
233 | } |
235 | } |
234 | |
236 | |
235 | void ref () EV_THROW () |
237 | void ref () throw () |
236 | { |
238 | { |
237 | ev_ref (EV_AX); |
239 | ev_ref (EV_AX); |
238 | } |
240 | } |
239 | |
241 | |
240 | void unref () EV_THROW () |
242 | void unref () throw () |
241 | { |
243 | { |
242 | ev_unref (EV_AX); |
244 | ev_unref (EV_AX); |
243 | } |
245 | } |
244 | |
246 | |
245 | void set_io_collect_interval (tstamp interval) EV_THROW () |
247 | void set_io_collect_interval (tstamp interval) throw () |
246 | { |
248 | { |
247 | ev_set_io_collect_interval (EV_AX_ interval); |
249 | ev_set_io_collect_interval (EV_AX_ interval); |
248 | } |
250 | } |
249 | |
251 | |
250 | void set_timeout_collect_interval (tstamp interval) EV_THROW () |
252 | void set_timeout_collect_interval (tstamp interval) throw () |
251 | { |
253 | { |
252 | ev_set_timeout_collect_interval (EV_AX_ interval); |
254 | ev_set_timeout_collect_interval (EV_AX_ interval); |
253 | } |
255 | } |
254 | |
256 | |
255 | // function callback |
257 | // function callback |
256 | void once (int fd, int events, tstamp timeout, void (*cb)(int, void *), void* arg = 0) EV_THROW () |
258 | void once (int fd, int events, tstamp timeout, void (*cb)(int, void *), void* arg = 0) throw () |
257 | { |
259 | { |
258 | ev_once (EV_AX_ fd, events, timeout, cb, arg); |
260 | ev_once (EV_AX_ fd, events, timeout, cb, arg); |
259 | } |
261 | } |
260 | |
262 | |
261 | // method callback |
263 | // method callback |
262 | template<class K, void (K::*method)(int)> |
264 | template<class K, void (K::*method)(int)> |
263 | void once (int fd, int events, tstamp timeout, K *object) EV_THROW () |
265 | void once (int fd, int events, tstamp timeout, K *object) throw () |
264 | { |
266 | { |
265 | once (fd, events, timeout, method_thunk<K, method>, object); |
267 | once (fd, events, timeout, method_thunk<K, method>, object); |
266 | } |
268 | } |
267 | |
269 | |
268 | template<class K, void (K::*method)(int)> |
270 | template<class K, void (K::*method)(int)> |
… | |
… | |
272 | (obj->*method) (revents); |
274 | (obj->*method) (revents); |
273 | } |
275 | } |
274 | |
276 | |
275 | // const method callback |
277 | // const method callback |
276 | template<class K, void (K::*method)(int) const> |
278 | template<class K, void (K::*method)(int) const> |
277 | void once (int fd, int events, tstamp timeout, const K *object) EV_THROW () |
279 | void once (int fd, int events, tstamp timeout, const K *object) throw () |
278 | { |
280 | { |
279 | once (fd, events, timeout, const_method_thunk<K, method>, object); |
281 | once (fd, events, timeout, const_method_thunk<K, method>, object); |
280 | } |
282 | } |
281 | |
283 | |
282 | template<class K, void (K::*method)(int) const> |
284 | template<class K, void (K::*method)(int) const> |
… | |
… | |
286 | (obj->*method) (revents); |
288 | (obj->*method) (revents); |
287 | } |
289 | } |
288 | |
290 | |
289 | // simple method callback |
291 | // simple method callback |
290 | template<class K, void (K::*method)()> |
292 | template<class K, void (K::*method)()> |
291 | void once (int fd, int events, tstamp timeout, K *object) EV_THROW () |
293 | void once (int fd, int events, tstamp timeout, K *object) throw () |
292 | { |
294 | { |
293 | once (fd, events, timeout, method_noargs_thunk<K, method>, object); |
295 | once (fd, events, timeout, method_noargs_thunk<K, method>, object); |
294 | } |
296 | } |
295 | |
297 | |
296 | template<class K, void (K::*method)()> |
298 | template<class K, void (K::*method)()> |
… | |
… | |
300 | (obj->*method) (); |
302 | (obj->*method) (); |
301 | } |
303 | } |
302 | |
304 | |
303 | // simpler function callback |
305 | // simpler function callback |
304 | template<void (*cb)(int)> |
306 | template<void (*cb)(int)> |
305 | void once (int fd, int events, tstamp timeout) EV_THROW () |
307 | void once (int fd, int events, tstamp timeout) throw () |
306 | { |
308 | { |
307 | once (fd, events, timeout, simpler_func_thunk<cb>); |
309 | once (fd, events, timeout, simpler_func_thunk<cb>); |
308 | } |
310 | } |
309 | |
311 | |
310 | template<void (*cb)(int)> |
312 | template<void (*cb)(int)> |
… | |
… | |
313 | (*cb) (revents); |
315 | (*cb) (revents); |
314 | } |
316 | } |
315 | |
317 | |
316 | // simplest function callback |
318 | // simplest function callback |
317 | template<void (*cb)()> |
319 | template<void (*cb)()> |
318 | void once (int fd, int events, tstamp timeout) EV_THROW () |
320 | void once (int fd, int events, tstamp timeout) throw () |
319 | { |
321 | { |
320 | once (fd, events, timeout, simplest_func_thunk<cb>); |
322 | once (fd, events, timeout, simplest_func_thunk<cb>); |
321 | } |
323 | } |
322 | |
324 | |
323 | template<void (*cb)()> |
325 | template<void (*cb)()> |
324 | static void simplest_func_thunk (int revents, void* arg) |
326 | static void simplest_func_thunk (int revents, void* arg) |
325 | { |
327 | { |
326 | (*cb) (); |
328 | (*cb) (); |
327 | } |
329 | } |
328 | |
330 | |
329 | void feed_fd_event (int fd, int revents) EV_THROW () |
331 | void feed_fd_event (int fd, int revents) throw () |
330 | { |
332 | { |
331 | ev_feed_fd_event (EV_AX_ fd, revents); |
333 | ev_feed_fd_event (EV_AX_ fd, revents); |
332 | } |
334 | } |
333 | |
335 | |
334 | void feed_signal_event (int signum) EV_THROW () |
336 | void feed_signal_event (int signum) throw () |
335 | { |
337 | { |
336 | ev_feed_signal_event (EV_AX_ signum); |
338 | ev_feed_signal_event (EV_AX_ signum); |
337 | } |
339 | } |
338 | |
340 | |
339 | #if EV_MULTIPLICITY |
341 | #if EV_MULTIPLICITY |
… | |
… | |
349 | dynamic_loop (unsigned int flags = AUTO) EV_THROW (bad_loop) |
351 | dynamic_loop (unsigned int flags = AUTO) EV_THROW (bad_loop) |
350 | : loop_ref (ev_loop_new (flags)) |
352 | : loop_ref (ev_loop_new (flags)) |
351 | { |
353 | { |
352 | } |
354 | } |
353 | |
355 | |
354 | ~dynamic_loop () EV_THROW () |
356 | ~dynamic_loop () throw () |
355 | { |
357 | { |
356 | ev_loop_destroy (EV_AX); |
358 | ev_loop_destroy (EV_AX); |
357 | EV_AX = 0; |
359 | EV_AX = 0; |
358 | } |
360 | } |
359 | |
361 | |
… | |
… | |
385 | throw bad_loop (); |
387 | throw bad_loop (); |
386 | #endif |
388 | #endif |
387 | } |
389 | } |
388 | #endif |
390 | #endif |
389 | |
391 | |
390 | ~default_loop () EV_THROW () |
392 | ~default_loop () throw () |
391 | { |
393 | { |
392 | ev_default_destroy (); |
394 | ev_default_destroy (); |
393 | #if EV_MULTIPLICITY |
395 | #if EV_MULTIPLICITY |
394 | EV_AX = 0; |
396 | EV_AX = 0; |
395 | #endif |
397 | #endif |
… | |
… | |
401 | |
403 | |
402 | default_loop & operator= (const default_loop &); |
404 | default_loop & operator= (const default_loop &); |
403 | |
405 | |
404 | }; |
406 | }; |
405 | |
407 | |
406 | inline loop_ref get_default_loop () EV_THROW () |
408 | inline loop_ref get_default_loop () throw () |
407 | { |
409 | { |
408 | #if EV_MULTIPLICITY |
410 | #if EV_MULTIPLICITY |
409 | return ev_default_loop (0); |
411 | return ev_default_loop (0); |
410 | #else |
412 | #else |
411 | return loop_ref (); |
413 | return loop_ref (); |
… | |
… | |
429 | struct base : ev_watcher |
431 | struct base : ev_watcher |
430 | { |
432 | { |
431 | #if EV_MULTIPLICITY |
433 | #if EV_MULTIPLICITY |
432 | EV_PX; |
434 | EV_PX; |
433 | |
435 | |
434 | void set (EV_PX) EV_THROW () |
436 | void set (EV_PX) throw () |
435 | { |
437 | { |
436 | this->EV_A = EV_A; |
438 | this->EV_A = EV_A; |
437 | } |
439 | } |
438 | #endif |
440 | #endif |
439 | |
441 | |
440 | base (EV_PX) EV_THROW () |
442 | base (EV_PX) throw () |
441 | #if EV_MULTIPLICITY |
443 | #if EV_MULTIPLICITY |
442 | : EV_A (EV_A) |
444 | : EV_A (EV_A) |
443 | #endif |
445 | #endif |
444 | { |
446 | { |
445 | ev_init (this, 0); |
447 | ev_init (this, 0); |
446 | } |
448 | } |
447 | |
449 | |
448 | void set_ (void *data, void (*cb)(EV_P_ ev_watcher *w, int revents)) EV_THROW () |
450 | void set_ (void *data, void (*cb)(EV_P_ ev_watcher *w, int revents)) throw () |
449 | { |
451 | { |
450 | this->data = data; |
452 | this->data = data; |
451 | ev_set_cb (static_cast<ev_watcher *>(this), cb); |
453 | ev_set_cb (static_cast<ev_watcher *>(this), cb); |
452 | } |
454 | } |
453 | |
455 | |
454 | // method callback |
456 | // method callback |
455 | template<class K, void (K::*method)(watcher &w, int)> |
457 | template<class K, void (K::*method)(watcher &w, int)> |
456 | void set (K *object) EV_THROW () |
458 | void set (K *object) throw () |
457 | { |
459 | { |
458 | set_ (object, method_thunk<K, method>); |
460 | set_ (object, method_thunk<K, method>); |
459 | } |
461 | } |
460 | |
462 | |
461 | template<class K, void (K::*method)(watcher &w, int)> |
463 | template<class K, void (K::*method)(watcher &w, int)> |
… | |
… | |
465 | (obj->*method) (*static_cast<watcher *>(w), revents); |
467 | (obj->*method) (*static_cast<watcher *>(w), revents); |
466 | } |
468 | } |
467 | |
469 | |
468 | // const method callback |
470 | // const method callback |
469 | template<class K, void (K::*method)(watcher &w, int) const> |
471 | template<class K, void (K::*method)(watcher &w, int) const> |
470 | void set (const K *object) EV_THROW () |
472 | void set (const K *object) throw () |
471 | { |
473 | { |
472 | set_ (object, const_method_thunk<K, method>); |
474 | set_ (object, const_method_thunk<K, method>); |
473 | } |
475 | } |
474 | |
476 | |
475 | template<class K, void (K::*method)(watcher &w, int) const> |
477 | template<class K, void (K::*method)(watcher &w, int) const> |
… | |
… | |
479 | (static_cast<K *>(w->data)->*method) (*static_cast<watcher *>(w), revents); |
481 | (static_cast<K *>(w->data)->*method) (*static_cast<watcher *>(w), revents); |
480 | } |
482 | } |
481 | |
483 | |
482 | // function callback |
484 | // function callback |
483 | template<void (*function)(watcher &w, int)> |
485 | template<void (*function)(watcher &w, int)> |
484 | void set (void *data = 0) EV_THROW () |
486 | void set (void *data = 0) throw () |
485 | { |
487 | { |
486 | set_ (data, function_thunk<function>); |
488 | set_ (data, function_thunk<function>); |
487 | } |
489 | } |
488 | |
490 | |
489 | template<void (*function)(watcher &w, int)> |
491 | template<void (*function)(watcher &w, int)> |
… | |
… | |
492 | function (*static_cast<watcher *>(w), revents); |
494 | function (*static_cast<watcher *>(w), revents); |
493 | } |
495 | } |
494 | |
496 | |
495 | // simple callback |
497 | // simple callback |
496 | template<class K, void (K::*method)()> |
498 | template<class K, void (K::*method)()> |
497 | void set (K *object) EV_THROW () |
499 | void set (K *object) throw () |
498 | { |
500 | { |
499 | set_ (object, method_noargs_thunk<K, method>); |
501 | set_ (object, method_noargs_thunk<K, method>); |
500 | } |
502 | } |
501 | |
503 | |
502 | template<class K, void (K::*method)()> |
504 | template<class K, void (K::*method)()> |
… | |
… | |
510 | { |
512 | { |
511 | return ev_cb (static_cast<ev_watcher *>(this)) |
513 | return ev_cb (static_cast<ev_watcher *>(this)) |
512 | (static_cast<ev_watcher *>(this), events); |
514 | (static_cast<ev_watcher *>(this), events); |
513 | } |
515 | } |
514 | |
516 | |
515 | bool is_active () const EV_THROW () |
517 | bool is_active () const throw () |
516 | { |
518 | { |
517 | return ev_is_active (static_cast<const ev_watcher *>(this)); |
519 | return ev_is_active (static_cast<const ev_watcher *>(this)); |
518 | } |
520 | } |
519 | |
521 | |
520 | bool is_pending () const EV_THROW () |
522 | bool is_pending () const throw () |
521 | { |
523 | { |
522 | return ev_is_pending (static_cast<const ev_watcher *>(this)); |
524 | return ev_is_pending (static_cast<const ev_watcher *>(this)); |
523 | } |
525 | } |
524 | |
526 | |
525 | void feed_event (int revents) EV_THROW () |
527 | void feed_event (int revents) throw () |
526 | { |
528 | { |
527 | ev_feed_event (EV_A_ static_cast<const ev_watcher *>(this), revents); |
529 | ev_feed_event (EV_A_ static_cast<const ev_watcher *>(this), revents); |
528 | } |
530 | } |
529 | }; |
531 | }; |
530 | |
532 | |
531 | inline tstamp now () EV_THROW () |
533 | inline tstamp now () throw () |
532 | { |
534 | { |
533 | return ev_time (); |
535 | return ev_time (); |
534 | } |
536 | } |
535 | |
537 | |
536 | inline void delay (tstamp interval) EV_THROW () |
538 | inline void delay (tstamp interval) throw () |
537 | { |
539 | { |
538 | ev_sleep (interval); |
540 | ev_sleep (interval); |
539 | } |
541 | } |
540 | |
542 | |
541 | inline int version_major () EV_THROW () |
543 | inline int version_major () throw () |
542 | { |
544 | { |
543 | return ev_version_major (); |
545 | return ev_version_major (); |
544 | } |
546 | } |
545 | |
547 | |
546 | inline int version_minor () EV_THROW () |
548 | inline int version_minor () throw () |
547 | { |
549 | { |
548 | return ev_version_minor (); |
550 | return ev_version_minor (); |
549 | } |
551 | } |
550 | |
552 | |
551 | inline unsigned int supported_backends () EV_THROW () |
553 | inline unsigned int supported_backends () throw () |
552 | { |
554 | { |
553 | return ev_supported_backends (); |
555 | return ev_supported_backends (); |
554 | } |
556 | } |
555 | |
557 | |
556 | inline unsigned int recommended_backends () EV_THROW () |
558 | inline unsigned int recommended_backends () throw () |
557 | { |
559 | { |
558 | return ev_recommended_backends (); |
560 | return ev_recommended_backends (); |
559 | } |
561 | } |
560 | |
562 | |
561 | inline unsigned int embeddable_backends () EV_THROW () |
563 | inline unsigned int embeddable_backends () throw () |
562 | { |
564 | { |
563 | return ev_embeddable_backends (); |
565 | return ev_embeddable_backends (); |
564 | } |
566 | } |
565 | |
567 | |
566 | inline void set_allocator (void *(*cb)(void *ptr, long size)) EV_THROW () |
568 | inline void set_allocator (void *(*cb)(void *ptr, long size)) throw () |
567 | { |
569 | { |
568 | ev_set_allocator (cb); |
570 | ev_set_allocator (cb); |
569 | } |
571 | } |
570 | |
572 | |
571 | inline void set_syserr_cb (void (*cb)(const char *msg)) EV_THROW () |
573 | inline void set_syserr_cb (void (*cb)(const char *msg)) throw () |
572 | { |
574 | { |
573 | ev_set_syserr_cb (cb); |
575 | ev_set_syserr_cb (cb); |
574 | } |
576 | } |
575 | |
577 | |
576 | #if EV_MULTIPLICITY |
578 | #if EV_MULTIPLICITY |
577 | #define EV_CONSTRUCT(cppstem,cstem) \ |
579 | #define EV_CONSTRUCT(cppstem,cstem) \ |
578 | (EV_PX = get_default_loop ()) EV_THROW () \ |
580 | (EV_PX = get_default_loop ()) throw () \ |
579 | : base<ev_ ## cstem, cppstem> (EV_A) \ |
581 | : base<ev_ ## cstem, cppstem> (EV_A) \ |
580 | { \ |
582 | { \ |
581 | } |
583 | } |
582 | #else |
584 | #else |
583 | #define EV_CONSTRUCT(cppstem,cstem) \ |
585 | #define EV_CONSTRUCT(cppstem,cstem) \ |
584 | () EV_THROW () \ |
586 | () throw () \ |
585 | { \ |
587 | { \ |
586 | } |
588 | } |
587 | #endif |
589 | #endif |
588 | |
590 | |
589 | /* using a template here would require quite a bit more lines, |
591 | /* using a template here would require quite a bit more lines, |
590 | * so a macro solution was chosen */ |
592 | * so a macro solution was chosen */ |
591 | #define EV_BEGIN_WATCHER(cppstem,cstem) \ |
593 | #define EV_BEGIN_WATCHER(cppstem,cstem) \ |
592 | \ |
594 | \ |
593 | struct cppstem : base<ev_ ## cstem, cppstem> \ |
595 | struct cppstem : base<ev_ ## cstem, cppstem> \ |
594 | { \ |
596 | { \ |
595 | void start () EV_THROW () \ |
597 | void start () throw () \ |
596 | { \ |
598 | { \ |
597 | ev_ ## cstem ## _start (EV_A_ static_cast<ev_ ## cstem *>(this)); \ |
599 | ev_ ## cstem ## _start (EV_A_ static_cast<ev_ ## cstem *>(this)); \ |
598 | } \ |
600 | } \ |
599 | \ |
601 | \ |
600 | void stop () EV_THROW () \ |
602 | void stop () throw () \ |
601 | { \ |
603 | { \ |
602 | ev_ ## cstem ## _stop (EV_A_ static_cast<ev_ ## cstem *>(this)); \ |
604 | ev_ ## cstem ## _stop (EV_A_ static_cast<ev_ ## cstem *>(this)); \ |
603 | } \ |
605 | } \ |
604 | \ |
606 | \ |
605 | cppstem EV_CONSTRUCT(cppstem,cstem) \ |
607 | cppstem EV_CONSTRUCT(cppstem,cstem) \ |
606 | \ |
608 | \ |
607 | ~cppstem () EV_THROW () \ |
609 | ~cppstem () throw () \ |
608 | { \ |
610 | { \ |
609 | stop (); \ |
611 | stop (); \ |
610 | } \ |
612 | } \ |
611 | \ |
613 | \ |
612 | using base<ev_ ## cstem, cppstem>::set; \ |
614 | using base<ev_ ## cstem, cppstem>::set; \ |
… | |
… | |
621 | |
623 | |
622 | #define EV_END_WATCHER(cppstem,cstem) \ |
624 | #define EV_END_WATCHER(cppstem,cstem) \ |
623 | }; |
625 | }; |
624 | |
626 | |
625 | EV_BEGIN_WATCHER (io, io) |
627 | EV_BEGIN_WATCHER (io, io) |
626 | void set (int fd, int events) EV_THROW () |
628 | void set (int fd, int events) throw () |
627 | { |
629 | { |
628 | int active = is_active (); |
630 | int active = is_active (); |
629 | if (active) stop (); |
631 | if (active) stop (); |
630 | ev_io_set (static_cast<ev_io *>(this), fd, events); |
632 | ev_io_set (static_cast<ev_io *>(this), fd, events); |
631 | if (active) start (); |
633 | if (active) start (); |
632 | } |
634 | } |
633 | |
635 | |
634 | void set (int events) EV_THROW () |
636 | void set (int events) throw () |
635 | { |
637 | { |
636 | int active = is_active (); |
638 | int active = is_active (); |
637 | if (active) stop (); |
639 | if (active) stop (); |
638 | ev_io_set (static_cast<ev_io *>(this), fd, events); |
640 | ev_io_set (static_cast<ev_io *>(this), fd, events); |
639 | if (active) start (); |
641 | if (active) start (); |
640 | } |
642 | } |
641 | |
643 | |
642 | void start (int fd, int events) EV_THROW () |
644 | void start (int fd, int events) throw () |
643 | { |
645 | { |
644 | set (fd, events); |
646 | set (fd, events); |
645 | start (); |
647 | start (); |
646 | } |
648 | } |
647 | EV_END_WATCHER (io, io) |
649 | EV_END_WATCHER (io, io) |
648 | |
650 | |
649 | EV_BEGIN_WATCHER (timer, timer) |
651 | EV_BEGIN_WATCHER (timer, timer) |
650 | void set (ev_tstamp after, ev_tstamp repeat = 0.) EV_THROW () |
652 | void set (ev_tstamp after, ev_tstamp repeat = 0.) throw () |
651 | { |
653 | { |
652 | int active = is_active (); |
654 | int active = is_active (); |
653 | if (active) stop (); |
655 | if (active) stop (); |
654 | ev_timer_set (static_cast<ev_timer *>(this), after, repeat); |
656 | ev_timer_set (static_cast<ev_timer *>(this), after, repeat); |
655 | if (active) start (); |
657 | if (active) start (); |
656 | } |
658 | } |
657 | |
659 | |
658 | void start (ev_tstamp after, ev_tstamp repeat = 0.) EV_THROW () |
660 | void start (ev_tstamp after, ev_tstamp repeat = 0.) throw () |
659 | { |
661 | { |
660 | set (after, repeat); |
662 | set (after, repeat); |
661 | start (); |
663 | start (); |
662 | } |
664 | } |
663 | |
665 | |
664 | void again () EV_THROW () |
666 | void again () throw () |
665 | { |
667 | { |
666 | ev_timer_again (EV_A_ static_cast<ev_timer *>(this)); |
668 | ev_timer_again (EV_A_ static_cast<ev_timer *>(this)); |
667 | } |
669 | } |
668 | EV_END_WATCHER (timer, timer) |
670 | EV_END_WATCHER (timer, timer) |
669 | |
671 | |
670 | #if EV_PERIODIC_ENABLE |
672 | #if EV_PERIODIC_ENABLE |
671 | EV_BEGIN_WATCHER (periodic, periodic) |
673 | EV_BEGIN_WATCHER (periodic, periodic) |
672 | void set (ev_tstamp at, ev_tstamp interval = 0.) EV_THROW () |
674 | void set (ev_tstamp at, ev_tstamp interval = 0.) throw () |
673 | { |
675 | { |
674 | int active = is_active (); |
676 | int active = is_active (); |
675 | if (active) stop (); |
677 | if (active) stop (); |
676 | ev_periodic_set (static_cast<ev_periodic *>(this), at, interval, 0); |
678 | ev_periodic_set (static_cast<ev_periodic *>(this), at, interval, 0); |
677 | if (active) start (); |
679 | if (active) start (); |
678 | } |
680 | } |
679 | |
681 | |
680 | void start (ev_tstamp at, ev_tstamp interval = 0.) EV_THROW () |
682 | void start (ev_tstamp at, ev_tstamp interval = 0.) throw () |
681 | { |
683 | { |
682 | set (at, interval); |
684 | set (at, interval); |
683 | start (); |
685 | start (); |
684 | } |
686 | } |
685 | |
687 | |
686 | void again () EV_THROW () |
688 | void again () throw () |
687 | { |
689 | { |
688 | ev_periodic_again (EV_A_ static_cast<ev_periodic *>(this)); |
690 | ev_periodic_again (EV_A_ static_cast<ev_periodic *>(this)); |
689 | } |
691 | } |
690 | EV_END_WATCHER (periodic, periodic) |
692 | EV_END_WATCHER (periodic, periodic) |
691 | #endif |
693 | #endif |
692 | |
694 | |
693 | EV_BEGIN_WATCHER (sig, signal) |
695 | EV_BEGIN_WATCHER (sig, signal) |
694 | void set (int signum) EV_THROW () |
696 | void set (int signum) throw () |
695 | { |
697 | { |
696 | int active = is_active (); |
698 | int active = is_active (); |
697 | if (active) stop (); |
699 | if (active) stop (); |
698 | ev_signal_set (static_cast<ev_signal *>(this), signum); |
700 | ev_signal_set (static_cast<ev_signal *>(this), signum); |
699 | if (active) start (); |
701 | if (active) start (); |
700 | } |
702 | } |
701 | |
703 | |
702 | void start (int signum) EV_THROW () |
704 | void start (int signum) throw () |
703 | { |
705 | { |
704 | set (signum); |
706 | set (signum); |
705 | start (); |
707 | start (); |
706 | } |
708 | } |
707 | EV_END_WATCHER (sig, signal) |
709 | EV_END_WATCHER (sig, signal) |
708 | |
710 | |
709 | EV_BEGIN_WATCHER (child, child) |
711 | EV_BEGIN_WATCHER (child, child) |
710 | void set (int pid) EV_THROW () |
712 | void set (int pid) throw () |
711 | { |
713 | { |
712 | int active = is_active (); |
714 | int active = is_active (); |
713 | if (active) stop (); |
715 | if (active) stop (); |
714 | ev_child_set (static_cast<ev_child *>(this), pid); |
716 | ev_child_set (static_cast<ev_child *>(this), pid); |
715 | if (active) start (); |
717 | if (active) start (); |
716 | } |
718 | } |
717 | |
719 | |
718 | void start (int pid) EV_THROW () |
720 | void start (int pid) throw () |
719 | { |
721 | { |
720 | set (pid); |
722 | set (pid); |
721 | start (); |
723 | start (); |
722 | } |
724 | } |
723 | EV_END_WATCHER (child, child) |
725 | EV_END_WATCHER (child, child) |
724 | |
726 | |
725 | #if EV_STAT_ENABLE |
727 | #if EV_STAT_ENABLE |
726 | EV_BEGIN_WATCHER (stat, stat) |
728 | EV_BEGIN_WATCHER (stat, stat) |
727 | void set (const char *path, ev_tstamp interval = 0.) EV_THROW () |
729 | void set (const char *path, ev_tstamp interval = 0.) throw () |
728 | { |
730 | { |
729 | int active = is_active (); |
731 | int active = is_active (); |
730 | if (active) stop (); |
732 | if (active) stop (); |
731 | ev_stat_set (static_cast<ev_stat *>(this), path, interval); |
733 | ev_stat_set (static_cast<ev_stat *>(this), path, interval); |
732 | if (active) start (); |
734 | if (active) start (); |
733 | } |
735 | } |
734 | |
736 | |
735 | void start (const char *path, ev_tstamp interval = 0.) EV_THROW () |
737 | void start (const char *path, ev_tstamp interval = 0.) throw () |
736 | { |
738 | { |
737 | stop (); |
739 | stop (); |
738 | set (path, interval); |
740 | set (path, interval); |
739 | start (); |
741 | start (); |
740 | } |
742 | } |
741 | |
743 | |
742 | void update () EV_THROW () |
744 | void update () throw () |
743 | { |
745 | { |
744 | ev_stat_stat (EV_A_ static_cast<ev_stat *>(this)); |
746 | ev_stat_stat (EV_A_ static_cast<ev_stat *>(this)); |
745 | } |
747 | } |
746 | EV_END_WATCHER (stat, stat) |
748 | EV_END_WATCHER (stat, stat) |
747 | #endif |
749 | #endif |
748 | |
750 | |
749 | EV_BEGIN_WATCHER (idle, idle) |
751 | EV_BEGIN_WATCHER (idle, idle) |
750 | void set () EV_THROW () { } |
752 | void set () throw () { } |
751 | EV_END_WATCHER (idle, idle) |
753 | EV_END_WATCHER (idle, idle) |
752 | |
754 | |
753 | EV_BEGIN_WATCHER (prepare, prepare) |
755 | EV_BEGIN_WATCHER (prepare, prepare) |
754 | void set () EV_THROW () { } |
756 | void set () throw () { } |
755 | EV_END_WATCHER (prepare, prepare) |
757 | EV_END_WATCHER (prepare, prepare) |
756 | |
758 | |
757 | EV_BEGIN_WATCHER (check, check) |
759 | EV_BEGIN_WATCHER (check, check) |
758 | void set () EV_THROW () { } |
760 | void set () throw () { } |
759 | EV_END_WATCHER (check, check) |
761 | EV_END_WATCHER (check, check) |
760 | |
762 | |
761 | #if EV_EMBED_ENABLE |
763 | #if EV_EMBED_ENABLE |
762 | EV_BEGIN_WATCHER (embed, embed) |
764 | EV_BEGIN_WATCHER (embed, embed) |
763 | void start (struct ev_loop *embedded_loop) EV_THROW () |
765 | void start (struct ev_loop *embedded_loop) throw () |
764 | { |
766 | { |
765 | stop (); |
767 | stop (); |
766 | ev_embed_set (static_cast<ev_embed *>(this), embedded_loop); |
768 | ev_embed_set (static_cast<ev_embed *>(this), embedded_loop); |
767 | start (); |
769 | start (); |
768 | } |
770 | } |
… | |
… | |
774 | EV_END_WATCHER (embed, embed) |
776 | EV_END_WATCHER (embed, embed) |
775 | #endif |
777 | #endif |
776 | |
778 | |
777 | #if EV_FORK_ENABLE |
779 | #if EV_FORK_ENABLE |
778 | EV_BEGIN_WATCHER (fork, fork) |
780 | EV_BEGIN_WATCHER (fork, fork) |
779 | void set () EV_THROW () { } |
781 | void set () throw () { } |
780 | EV_END_WATCHER (fork, fork) |
782 | EV_END_WATCHER (fork, fork) |
781 | #endif |
783 | #endif |
782 | |
784 | |
783 | #undef EV_PX |
785 | #undef EV_PX |
784 | #undef EV_PX_ |
786 | #undef EV_PX_ |