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

Comparing libev/ev++.h (file contents):
Revision 1.45 by root, Fri Jul 10 00:36:21 2009 UTC vs.
Revision 1.55 by root, Sun Oct 24 17:58:41 2010 UTC

1/* 1/*
2 * libev simple C++ wrapper classes 2 * libev simple C++ wrapper classes
3 * 3 *
4 * Copyright (c) 2007,2008 Marc Alexander Lehmann <libev@schmorp.de> 4 * Copyright (c) 2007,2008,2010 Marc Alexander Lehmann <libev@schmorp.de>
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without modifica- 7 * Redistribution and use in source and binary forms, with or without modifica-
8 * tion, are permitted provided that the following conditions are met: 8 * tion, are permitted provided that the following conditions are met:
9 * 9 *
62 { 62 {
63 UNDEF = EV_UNDEF, 63 UNDEF = EV_UNDEF,
64 NONE = EV_NONE, 64 NONE = EV_NONE,
65 READ = EV_READ, 65 READ = EV_READ,
66 WRITE = EV_WRITE, 66 WRITE = EV_WRITE,
67#if EV_COMPAT3
67 TIMEOUT = EV_TIMEOUT, 68 TIMEOUT = EV_TIMEOUT,
69#endif
70 TIMER = EV_TIMER,
68 PERIODIC = EV_PERIODIC, 71 PERIODIC = EV_PERIODIC,
69 SIGNAL = EV_SIGNAL, 72 SIGNAL = EV_SIGNAL,
70 CHILD = EV_CHILD, 73 CHILD = EV_CHILD,
71 STAT = EV_STAT, 74 STAT = EV_STAT,
72 IDLE = EV_IDLE, 75 IDLE = EV_IDLE,
74 PREPARE = EV_PREPARE, 77 PREPARE = EV_PREPARE,
75 FORK = EV_FORK, 78 FORK = EV_FORK,
76 ASYNC = EV_ASYNC, 79 ASYNC = EV_ASYNC,
77 EMBED = EV_EMBED, 80 EMBED = EV_EMBED,
78# undef ERROR // some systems stupidly #define ERROR 81# undef ERROR // some systems stupidly #define ERROR
79 ERROR = EV_ERROR, 82 ERROR = EV_ERROR
80 }; 83 };
81 84
82 enum 85 enum
83 { 86 {
84 AUTO = EVFLAG_AUTO, 87 AUTO = EVFLAG_AUTO,
93 PORT = EVBACKEND_PORT 96 PORT = EVBACKEND_PORT
94 }; 97 };
95 98
96 enum 99 enum
97 { 100 {
101#if EV_COMPAT3
98 NONBLOCK = EVLOOP_NONBLOCK, 102 NONBLOCK = EVLOOP_NONBLOCK,
99 ONESHOT = EVLOOP_ONESHOT 103 ONESHOT = EVLOOP_ONESHOT,
104#endif
105 NOWAIT = EVRUN_NOWAIT,
106 ONCE = EVRUN_ONCE
100 }; 107 };
101 108
102 enum how_t 109 enum how_t
103 { 110 {
104 ONE = EVUNLOOP_ONE, 111 ONE = EVBREAK_ONE,
105 ALL = EVUNLOOP_ALL 112 ALL = EVBREAK_ALL
106 }; 113 };
107 114
108 struct bad_loop 115 struct bad_loop
109#if EV_USE_STDEXCEPT 116#if EV_USE_STDEXCEPT
110 : std::runtime_error 117 : std::runtime_error
186 { 193 {
187 return EV_AX == ev_default_loop (0); 194 return EV_AX == ev_default_loop (0);
188 } 195 }
189#endif 196#endif
190 197
198#if EV_COMPAT3
191 void loop (int flags = 0) 199 void loop (int flags = 0)
192 { 200 {
193 ev_loop (EV_AX_ flags); 201 ev_run (EV_AX_ flags);
194 } 202 }
195 203
196 void unloop (how_t how = ONE) throw () 204 void unloop (how_t how = ONE) throw ()
197 { 205 {
198 ev_unloop (EV_AX_ how); 206 ev_break (EV_AX_ how);
207 }
208#endif
209
210 void run (int flags = 0)
211 {
212 ev_run (EV_AX_ flags);
213 }
214
215 void break_loop (how_t how = ONE) throw ()
216 {
217 ev_break (EV_AX_ how);
199 } 218 }
200 219
201 void post_fork () throw () 220 void post_fork () throw ()
202 { 221 {
203#if EV_MULTIPLICITY
204 ev_loop_fork (EV_AX); 222 ev_loop_fork (EV_AX);
205#else
206 ev_default_fork ();
207#endif
208 } 223 }
209 224
210 unsigned int backend () const throw () 225 unsigned int backend () const throw ()
211 { 226 {
212 return ev_backend (EV_AX); 227 return ev_backend (EV_AX);
225 void unref () throw () 240 void unref () throw ()
226 { 241 {
227 ev_unref (EV_AX); 242 ev_unref (EV_AX);
228 } 243 }
229 244
230#if EV_MINIMAL < 2 245#if EV_FEATURE_API
231 unsigned int count () const throw () 246 unsigned int iteration () const throw ()
232 { 247 {
233 return ev_loop_count (EV_AX); 248 return ev_iteration (EV_AX);
234 } 249 }
235 250
236 unsigned int depth () const throw () 251 unsigned int depth () const throw ()
237 { 252 {
238 return ev_loop_depth (EV_AX); 253 return ev_depth (EV_AX);
239 } 254 }
240 255
241 void set_io_collect_interval (tstamp interval) throw () 256 void set_io_collect_interval (tstamp interval) throw ()
242 { 257 {
243 ev_set_io_collect_interval (EV_AX_ interval); 258 ev_set_io_collect_interval (EV_AX_ interval);
373#else 388#else
374 !ev_default_loop (flags) 389 !ev_default_loop (flags)
375#endif 390#endif
376 ) 391 )
377 throw bad_loop (); 392 throw bad_loop ();
378 }
379
380 ~default_loop () throw ()
381 {
382 ev_default_destroy ();
383 } 393 }
384 394
385 private: 395 private:
386 default_loop (const default_loop &); 396 default_loop (const default_loop &);
387 default_loop &operator = (const default_loop &); 397 default_loop &operator = (const default_loop &);
413 struct base : ev_watcher 423 struct base : ev_watcher
414 { 424 {
415 #if EV_MULTIPLICITY 425 #if EV_MULTIPLICITY
416 EV_PX; 426 EV_PX;
417 427
428 // loop set
418 void set (EV_P) throw () 429 void set (EV_P) throw ()
419 { 430 {
420 this->EV_A = EV_A; 431 this->EV_A = EV_A;
421 } 432 }
422 #endif 433 #endif
478 } 489 }
479 490
480 template<class K, void (K::*method)()> 491 template<class K, void (K::*method)()>
481 static void method_noargs_thunk (EV_P_ ev_watcher *w, int revents) 492 static void method_noargs_thunk (EV_P_ ev_watcher *w, int revents)
482 { 493 {
483 static_cast<K *>(w->data)->*method 494 (static_cast<K *>(w->data)->*method)
484 (); 495 ();
485 } 496 }
486 497
487 void operator ()(int events = EV_UNDEF) 498 void operator ()(int events = EV_UNDEF)
488 { 499 {
642 653
643 void again () throw () 654 void again () throw ()
644 { 655 {
645 ev_timer_again (EV_A_ static_cast<ev_timer *>(this)); 656 ev_timer_again (EV_A_ static_cast<ev_timer *>(this));
646 } 657 }
658
659 ev_tstamp remaining ()
660 {
661 return ev_timer_remaining (EV_A_ static_cast<ev_timer *>(this));
662 }
647 EV_END_WATCHER (timer, timer) 663 EV_END_WATCHER (timer, timer)
648 664
649 #if EV_PERIODIC_ENABLE 665 #if EV_PERIODIC_ENABLE
650 EV_BEGIN_WATCHER (periodic, periodic) 666 EV_BEGIN_WATCHER (periodic, periodic)
651 void set (ev_tstamp at, ev_tstamp interval = 0.) throw () 667 void set (ev_tstamp at, ev_tstamp interval = 0.) throw ()
667 ev_periodic_again (EV_A_ static_cast<ev_periodic *>(this)); 683 ev_periodic_again (EV_A_ static_cast<ev_periodic *>(this));
668 } 684 }
669 EV_END_WATCHER (periodic, periodic) 685 EV_END_WATCHER (periodic, periodic)
670 #endif 686 #endif
671 687
688 #if EV_SIGNAL_ENABLE
672 EV_BEGIN_WATCHER (sig, signal) 689 EV_BEGIN_WATCHER (sig, signal)
673 void set (int signum) throw () 690 void set (int signum) throw ()
674 { 691 {
675 int active = is_active (); 692 int active = is_active ();
676 if (active) stop (); 693 if (active) stop ();
682 { 699 {
683 set (signum); 700 set (signum);
684 start (); 701 start ();
685 } 702 }
686 EV_END_WATCHER (sig, signal) 703 EV_END_WATCHER (sig, signal)
704 #endif
687 705
706 #if EV_CHILD_ENABLE
688 EV_BEGIN_WATCHER (child, child) 707 EV_BEGIN_WATCHER (child, child)
689 void set (int pid, int trace = 0) throw () 708 void set (int pid, int trace = 0) throw ()
690 { 709 {
691 int active = is_active (); 710 int active = is_active ();
692 if (active) stop (); 711 if (active) stop ();
698 { 717 {
699 set (pid, trace); 718 set (pid, trace);
700 start (); 719 start ();
701 } 720 }
702 EV_END_WATCHER (child, child) 721 EV_END_WATCHER (child, child)
722 #endif
703 723
704 #if EV_STAT_ENABLE 724 #if EV_STAT_ENABLE
705 EV_BEGIN_WATCHER (stat, stat) 725 EV_BEGIN_WATCHER (stat, stat)
706 void set (const char *path, ev_tstamp interval = 0.) throw () 726 void set (const char *path, ev_tstamp interval = 0.) throw ()
707 { 727 {
723 ev_stat_stat (EV_A_ static_cast<ev_stat *>(this)); 743 ev_stat_stat (EV_A_ static_cast<ev_stat *>(this));
724 } 744 }
725 EV_END_WATCHER (stat, stat) 745 EV_END_WATCHER (stat, stat)
726 #endif 746 #endif
727 747
748 #if EV_IDLE_ENABLE
728 EV_BEGIN_WATCHER (idle, idle) 749 EV_BEGIN_WATCHER (idle, idle)
729 void set () throw () { } 750 void set () throw () { }
730 EV_END_WATCHER (idle, idle) 751 EV_END_WATCHER (idle, idle)
752 #endif
731 753
754 #if EV_PREPARE_ENABLE
732 EV_BEGIN_WATCHER (prepare, prepare) 755 EV_BEGIN_WATCHER (prepare, prepare)
733 void set () throw () { } 756 void set () throw () { }
734 EV_END_WATCHER (prepare, prepare) 757 EV_END_WATCHER (prepare, prepare)
758 #endif
735 759
760 #if EV_CHECK_ENABLE
736 EV_BEGIN_WATCHER (check, check) 761 EV_BEGIN_WATCHER (check, check)
737 void set () throw () { } 762 void set () throw () { }
738 EV_END_WATCHER (check, check) 763 EV_END_WATCHER (check, check)
764 #endif
739 765
740 #if EV_EMBED_ENABLE 766 #if EV_EMBED_ENABLE
741 EV_BEGIN_WATCHER (embed, embed) 767 EV_BEGIN_WATCHER (embed, embed)
742 void set (struct ev_loop *embedded_loop) throw () 768 void set (struct ev_loop *embedded_loop) throw ()
743 { 769 {
766 EV_END_WATCHER (fork, fork) 792 EV_END_WATCHER (fork, fork)
767 #endif 793 #endif
768 794
769 #if EV_ASYNC_ENABLE 795 #if EV_ASYNC_ENABLE
770 EV_BEGIN_WATCHER (async, async) 796 EV_BEGIN_WATCHER (async, async)
771 void set () throw () { }
772
773 void send () throw () 797 void send () throw ()
774 { 798 {
775 ev_async_send (EV_A_ static_cast<ev_async *>(this)); 799 ev_async_send (EV_A_ static_cast<ev_async *>(this));
776 } 800 }
777 801

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines