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.54 by root, Fri Oct 22 05:57:55 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 222#if EV_MULTIPLICITY
225 void unref () throw () 244 void unref () throw ()
226 { 245 {
227 ev_unref (EV_AX); 246 ev_unref (EV_AX);
228 } 247 }
229 248
230#if EV_MINIMAL < 2 249#if EV_FEATURE_API
231 unsigned int count () const throw () 250 unsigned int iteration () const throw ()
232 { 251 {
233 return ev_loop_count (EV_AX); 252 return ev_iteration (EV_AX);
234 } 253 }
235 254
236 unsigned int depth () const throw () 255 unsigned int depth () const throw ()
237 { 256 {
238 return ev_loop_depth (EV_AX); 257 return ev_depth (EV_AX);
239 } 258 }
240 259
241 void set_io_collect_interval (tstamp interval) throw () 260 void set_io_collect_interval (tstamp interval) throw ()
242 { 261 {
243 ev_set_io_collect_interval (EV_AX_ interval); 262 ev_set_io_collect_interval (EV_AX_ interval);
413 struct base : ev_watcher 432 struct base : ev_watcher
414 { 433 {
415 #if EV_MULTIPLICITY 434 #if EV_MULTIPLICITY
416 EV_PX; 435 EV_PX;
417 436
437 // loop set
418 void set (EV_P) throw () 438 void set (EV_P) throw ()
419 { 439 {
420 this->EV_A = EV_A; 440 this->EV_A = EV_A;
421 } 441 }
422 #endif 442 #endif
478 } 498 }
479 499
480 template<class K, void (K::*method)()> 500 template<class K, void (K::*method)()>
481 static void method_noargs_thunk (EV_P_ ev_watcher *w, int revents) 501 static void method_noargs_thunk (EV_P_ ev_watcher *w, int revents)
482 { 502 {
483 static_cast<K *>(w->data)->*method 503 (static_cast<K *>(w->data)->*method)
484 (); 504 ();
485 } 505 }
486 506
487 void operator ()(int events = EV_UNDEF) 507 void operator ()(int events = EV_UNDEF)
488 { 508 {
642 662
643 void again () throw () 663 void again () throw ()
644 { 664 {
645 ev_timer_again (EV_A_ static_cast<ev_timer *>(this)); 665 ev_timer_again (EV_A_ static_cast<ev_timer *>(this));
646 } 666 }
667
668 ev_tstamp remaining ()
669 {
670 return ev_timer_remaining (EV_A_ static_cast<ev_timer *>(this));
671 }
647 EV_END_WATCHER (timer, timer) 672 EV_END_WATCHER (timer, timer)
648 673
649 #if EV_PERIODIC_ENABLE 674 #if EV_PERIODIC_ENABLE
650 EV_BEGIN_WATCHER (periodic, periodic) 675 EV_BEGIN_WATCHER (periodic, periodic)
651 void set (ev_tstamp at, ev_tstamp interval = 0.) throw () 676 void set (ev_tstamp at, ev_tstamp interval = 0.) throw ()
667 ev_periodic_again (EV_A_ static_cast<ev_periodic *>(this)); 692 ev_periodic_again (EV_A_ static_cast<ev_periodic *>(this));
668 } 693 }
669 EV_END_WATCHER (periodic, periodic) 694 EV_END_WATCHER (periodic, periodic)
670 #endif 695 #endif
671 696
697 #if EV_SIGNAL_ENABLE
672 EV_BEGIN_WATCHER (sig, signal) 698 EV_BEGIN_WATCHER (sig, signal)
673 void set (int signum) throw () 699 void set (int signum) throw ()
674 { 700 {
675 int active = is_active (); 701 int active = is_active ();
676 if (active) stop (); 702 if (active) stop ();
682 { 708 {
683 set (signum); 709 set (signum);
684 start (); 710 start ();
685 } 711 }
686 EV_END_WATCHER (sig, signal) 712 EV_END_WATCHER (sig, signal)
713 #endif
687 714
715 #if EV_CHILD_ENABLE
688 EV_BEGIN_WATCHER (child, child) 716 EV_BEGIN_WATCHER (child, child)
689 void set (int pid, int trace = 0) throw () 717 void set (int pid, int trace = 0) throw ()
690 { 718 {
691 int active = is_active (); 719 int active = is_active ();
692 if (active) stop (); 720 if (active) stop ();
698 { 726 {
699 set (pid, trace); 727 set (pid, trace);
700 start (); 728 start ();
701 } 729 }
702 EV_END_WATCHER (child, child) 730 EV_END_WATCHER (child, child)
731 #endif
703 732
704 #if EV_STAT_ENABLE 733 #if EV_STAT_ENABLE
705 EV_BEGIN_WATCHER (stat, stat) 734 EV_BEGIN_WATCHER (stat, stat)
706 void set (const char *path, ev_tstamp interval = 0.) throw () 735 void set (const char *path, ev_tstamp interval = 0.) throw ()
707 { 736 {
723 ev_stat_stat (EV_A_ static_cast<ev_stat *>(this)); 752 ev_stat_stat (EV_A_ static_cast<ev_stat *>(this));
724 } 753 }
725 EV_END_WATCHER (stat, stat) 754 EV_END_WATCHER (stat, stat)
726 #endif 755 #endif
727 756
757 #if EV_IDLE_ENABLE
728 EV_BEGIN_WATCHER (idle, idle) 758 EV_BEGIN_WATCHER (idle, idle)
729 void set () throw () { } 759 void set () throw () { }
730 EV_END_WATCHER (idle, idle) 760 EV_END_WATCHER (idle, idle)
761 #endif
731 762
763 #if EV_PREPARE_ENABLE
732 EV_BEGIN_WATCHER (prepare, prepare) 764 EV_BEGIN_WATCHER (prepare, prepare)
733 void set () throw () { } 765 void set () throw () { }
734 EV_END_WATCHER (prepare, prepare) 766 EV_END_WATCHER (prepare, prepare)
767 #endif
735 768
769 #if EV_CHECK_ENABLE
736 EV_BEGIN_WATCHER (check, check) 770 EV_BEGIN_WATCHER (check, check)
737 void set () throw () { } 771 void set () throw () { }
738 EV_END_WATCHER (check, check) 772 EV_END_WATCHER (check, check)
773 #endif
739 774
740 #if EV_EMBED_ENABLE 775 #if EV_EMBED_ENABLE
741 EV_BEGIN_WATCHER (embed, embed) 776 EV_BEGIN_WATCHER (embed, embed)
742 void set (struct ev_loop *embedded_loop) throw () 777 void set (struct ev_loop *embedded_loop) throw ()
743 { 778 {
766 EV_END_WATCHER (fork, fork) 801 EV_END_WATCHER (fork, fork)
767 #endif 802 #endif
768 803
769 #if EV_ASYNC_ENABLE 804 #if EV_ASYNC_ENABLE
770 EV_BEGIN_WATCHER (async, async) 805 EV_BEGIN_WATCHER (async, async)
771 void set () throw () { }
772
773 void send () throw () 806 void send () throw ()
774 { 807 {
775 ev_async_send (EV_A_ static_cast<ev_async *>(this)); 808 ev_async_send (EV_A_ static_cast<ev_async *>(this));
776 } 809 }
777 810

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines