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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines