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.36 by root, Tue Jan 22 18:09:23 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_
110#endif 131#endif
111 132
112 struct loop_ref 133 struct loop_ref
113 { 134 {
114 135
115 loop_ref (EV_P) 136 loop_ref (EV_P) throw ()
116#if EV_MULTIPLICITY 137#if EV_MULTIPLICITY
117 : EV_AX (EV_A) 138 : EV_AX (EV_A)
118#endif 139#endif
119 {
120 } 140 {
141 }
121 142
122 bool operator== (const loop_ref &other) const 143 bool operator == (const loop_ref &other) const throw ()
123 { 144 {
124#if EV_MULTIPLICITY 145#if EV_MULTIPLICITY
125 return this->EV_AX == other.EV_AX; 146 return EV_AX == other.EV_AX;
126#else 147#else
127 return true; 148 return true;
128#endif 149#endif
129 } 150 }
130 151
131 bool operator!= (const loop_ref &other) const 152 bool operator != (const loop_ref &other) const throw ()
132 { 153 {
133#if EV_MULTIPLICITY 154#if EV_MULTIPLICITY
134 return ! (*this == other); 155 return ! (*this == other);
135#else 156#else
136 return false; 157 return false;
137#endif 158#endif
138 } 159 }
139 160
140#if EV_MULTIPLICITY 161#if EV_MULTIPLICITY
141 bool operator== (struct ev_loop *other) const 162 bool operator== (struct ev_loop *other) const throw ()
142 { 163 {
143 return this->EV_AX == other; 164 return this->EV_AX == other;
144 } 165 }
145 166
146 bool operator!= (struct ev_loop *other) const 167 bool operator!= (struct ev_loop *other) const throw ()
147 { 168 {
148 return ! (*this == other); 169 return ! (*this == other);
149 } 170 }
150 171
151 bool operator== (const struct ev_loop *other) const 172 bool operator== (const struct ev_loop *other) const throw ()
152 { 173 {
153 return this->EV_AX == other; 174 return this->EV_AX == other;
154 } 175 }
155 176
156 bool operator!= (const struct ev_loop *other) const 177 bool operator!= (const struct ev_loop *other) const throw ()
157 { 178 {
158 return (*this == other); 179 return (*this == other);
159 } 180 }
160 181
161 operator struct ev_loop * () const 182 operator struct ev_loop * () const throw ()
162 { 183 {
163 return EV_AX; 184 return EV_AX;
164 } 185 }
165 186
166 operator const struct ev_loop * () const 187 operator const struct ev_loop * () const throw ()
167 { 188 {
168 return EV_AX; 189 return EV_AX;
169 } 190 }
170 191
171 bool is_default () const 192 bool is_default () const throw ()
172 { 193 {
173 return EV_AX == ev_default_loop (0); 194 return EV_AX == ev_default_loop (0);
174 } 195 }
175#endif 196#endif
176 197
177 void loop (int flags = 0) 198 void loop (int flags = 0)
178 { 199 {
179 ev_loop (EV_AX_ flags); 200 ev_loop (EV_AX_ flags);
180 } 201 }
181 202
182 void unloop (how_t how = ONE) 203 void unloop (how_t how = ONE) throw ()
183 { 204 {
184 ev_unloop (EV_AX_ how); 205 ev_unloop (EV_AX_ how);
185 } 206 }
186 207
187 void post_fork () 208 void post_fork () throw ()
188 { 209 {
189#if EV_MULTIPLICITY 210#if EV_MULTIPLICITY
190 ev_loop_fork (EV_AX); 211 ev_loop_fork (EV_AX);
191#else 212#else
192 ev_default_fork (); 213 ev_default_fork ();
193#endif 214#endif
194 } 215 }
195 216
196 unsigned int count () const 217 unsigned int count () const throw ()
197 { 218 {
198 return ev_loop_count (EV_AX); 219 return ev_loop_count (EV_AX);
199 } 220 }
200 221
201 unsigned int backend () const 222 unsigned int backend () const throw ()
202 { 223 {
203 return ev_backend (EV_AX); 224 return ev_backend (EV_AX);
204 } 225 }
205 226
206 tstamp now () const 227 tstamp now () const throw ()
207 { 228 {
208 return ev_now (EV_AX); 229 return ev_now (EV_AX);
209 } 230 }
210 231
211 void ref () 232 void ref () throw ()
212 { 233 {
213 ev_ref (EV_AX); 234 ev_ref (EV_AX);
214 } 235 }
215 236
216 void unref () 237 void unref () throw ()
217 { 238 {
218 ev_unref (EV_AX); 239 ev_unref (EV_AX);
219 } 240 }
220 241
221 void set_io_collect_interval (tstamp interval) 242 void set_io_collect_interval (tstamp interval) throw ()
222 { 243 {
223 ev_set_io_collect_interval (EV_AX_ interval); 244 ev_set_io_collect_interval (EV_AX_ interval);
224 } 245 }
225 246
226 void set_timeout_collect_interval (tstamp interval) 247 void set_timeout_collect_interval (tstamp interval) throw ()
227 { 248 {
228 ev_set_timeout_collect_interval (EV_AX_ interval); 249 ev_set_timeout_collect_interval (EV_AX_ interval);
229 } 250 }
230 251
231 // function callback 252 // function callback
232 void once (int fd, int events, tstamp timeout, void (*cb)(int, void *), void* arg = 0) 253 void once (int fd, int events, tstamp timeout, void (*cb)(int, void *), void* arg = 0) throw ()
233 { 254 {
234 ev_once (EV_AX_ fd, events, timeout, cb, arg); 255 ev_once (EV_AX_ fd, events, timeout, cb, arg);
235 } 256 }
236 257
237 // method callback 258 // method callback
238 template<class K, void (K::*method)(int)> 259 template<class K, void (K::*method)(int)>
239 void once (int fd, int events, tstamp timeout, K *object) 260 void once (int fd, int events, tstamp timeout, K *object) throw ()
240 { 261 {
241 once (fd, events, timeout, method_thunk<K, method>, object); 262 once (fd, events, timeout, method_thunk<K, method>, object);
242 } 263 }
243 264
244 template<class K, void (K::*method)(int)> 265 template<class K, void (K::*method)(int)>
248 (obj->*method) (revents); 269 (obj->*method) (revents);
249 } 270 }
250 271
251 // const method callback 272 // const method callback
252 template<class K, void (K::*method)(int) const> 273 template<class K, void (K::*method)(int) const>
253 void once (int fd, int events, tstamp timeout, const K *object) 274 void once (int fd, int events, tstamp timeout, const K *object) throw ()
254 { 275 {
255 once (fd, events, timeout, const_method_thunk<K, method>, object); 276 once (fd, events, timeout, const_method_thunk<K, method>, object);
256 } 277 }
257 278
258 template<class K, void (K::*method)(int) const> 279 template<class K, void (K::*method)(int) const>
262 (obj->*method) (revents); 283 (obj->*method) (revents);
263 } 284 }
264 285
265 // simple method callback 286 // simple method callback
266 template<class K, void (K::*method)()> 287 template<class K, void (K::*method)()>
267 void once (int fd, int events, tstamp timeout, K *object) 288 void once (int fd, int events, tstamp timeout, K *object) throw ()
268 { 289 {
269 once (fd, events, timeout, method_noargs_thunk<K, method>, object); 290 once (fd, events, timeout, method_noargs_thunk<K, method>, object);
270 } 291 }
271 292
272 template<class K, void (K::*method)()> 293 template<class K, void (K::*method)()>
276 (obj->*method) (); 297 (obj->*method) ();
277 } 298 }
278 299
279 // simpler function callback 300 // simpler function callback
280 template<void (*cb)(int)> 301 template<void (*cb)(int)>
281 void once (int fd, int events, tstamp timeout) 302 void once (int fd, int events, tstamp timeout) throw ()
282 { 303 {
283 once (fd, events, timeout, simpler_func_thunk<cb>); 304 once (fd, events, timeout, simpler_func_thunk<cb>);
284 } 305 }
285 306
286 template<void (*cb)(int)> 307 template<void (*cb)(int)>
289 (*cb) (revents); 310 (*cb) (revents);
290 } 311 }
291 312
292 // simplest function callback 313 // simplest function callback
293 template<void (*cb)()> 314 template<void (*cb)()>
294 void once (int fd, int events, tstamp timeout) 315 void once (int fd, int events, tstamp timeout) throw ()
295 { 316 {
296 once (fd, events, timeout, simplest_func_thunk<cb>); 317 once (fd, events, timeout, simplest_func_thunk<cb>);
297 } 318 }
298 319
299 template<void (*cb)()> 320 template<void (*cb)()>
300 static void simplest_func_thunk (int revents, void* arg) 321 static void simplest_func_thunk (int revents, void* arg)
301 { 322 {
302 (*cb) (); 323 (*cb) ();
303 } 324 }
304 325
305 void feed_fd_event (int fd, int revents) 326 void feed_fd_event (int fd, int revents) throw ()
306 { 327 {
307 ev_feed_fd_event (EV_AX_ fd, revents); 328 ev_feed_fd_event (EV_AX_ fd, revents);
308 } 329 }
309 330
310 void feed_signal_event (int signum) 331 void feed_signal_event (int signum) throw ()
311 { 332 {
312 ev_feed_signal_event (EV_AX_ signum); 333 ev_feed_signal_event (EV_AX_ signum);
313 } 334 }
314 335
315#if EV_MULTIPLICITY 336#if EV_MULTIPLICITY
317#endif 338#endif
318 339
319 }; 340 };
320 341
321#if EV_MULTIPLICITY 342#if EV_MULTIPLICITY
322 struct dynamic_loop: loop_ref 343 struct dynamic_loop : loop_ref
323 { 344 {
324 345
325 dynamic_loop (unsigned int flags = AUTO) 346 dynamic_loop (unsigned int flags = AUTO) throw (bad_loop)
326 : loop_ref (ev_loop_new (flags)) 347 : loop_ref (ev_loop_new (flags))
327 {
328 } 348 {
349 if (!EV_AX)
350 throw bad_loop ();
351 }
329 352
330 ~dynamic_loop () 353 ~dynamic_loop () throw ()
331 { 354 {
332 ev_loop_destroy (EV_AX); 355 ev_loop_destroy (EV_AX);
333 EV_AX = 0; 356 EV_AX = 0;
334 } 357 }
335 358
340 dynamic_loop & operator= (const dynamic_loop &); 363 dynamic_loop & operator= (const dynamic_loop &);
341 364
342 }; 365 };
343#endif 366#endif
344 367
345 struct default_loop: loop_ref 368 struct default_loop : loop_ref
346 { 369 {
347 370
348 default_loop (unsigned int flags = AUTO) 371 default_loop (unsigned int flags = AUTO) throw (bad_loop)
349#if EV_MULTIPLICITY 372#if EV_MULTIPLICITY
350 : loop_ref (ev_default_loop (flags)) 373 : loop_ref (ev_default_loop (flags))
351 { 374#endif
352 } 375 {
376 if (
377#if EV_MULTIPLICITY
378 !EV_AX
353#else 379#else
354 {
355 ev_default_loop (flags); 380 !ev_default_loop (flags)
356 }
357#endif 381#endif
382 )
383 throw bad_loop ();
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