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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines