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

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines