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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines