ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libev/ev++.h
(Generate patch)

Comparing libev/ev++.h (file contents):
Revision 1.29 by llucax, Fri Jan 18 18:15:01 2008 UTC vs.
Revision 1.35 by llucax, Tue Jan 22 17:57:17 2008 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines