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

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines