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

Comparing libev/ev++.h (file contents):
Revision 1.44 by root, Wed Dec 3 15:23:44 2008 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
205#else 224#else
206 ev_default_fork (); 225 ev_default_fork ();
207#endif 226#endif
208 } 227 }
209 228
210 unsigned int count () const throw ()
211 {
212 return ev_loop_count (EV_AX);
213 }
214
215 unsigned int backend () const throw () 229 unsigned int backend () const throw ()
216 { 230 {
217 return ev_backend (EV_AX); 231 return ev_backend (EV_AX);
218 } 232 }
219 233
230 void unref () throw () 244 void unref () throw ()
231 { 245 {
232 ev_unref (EV_AX); 246 ev_unref (EV_AX);
233 } 247 }
234 248
249#if EV_FEATURE_API
250 unsigned int iteration () const throw ()
251 {
252 return ev_iteration (EV_AX);
253 }
254
255 unsigned int depth () const throw ()
256 {
257 return ev_depth (EV_AX);
258 }
259
235 void set_io_collect_interval (tstamp interval) throw () 260 void set_io_collect_interval (tstamp interval) throw ()
236 { 261 {
237 ev_set_io_collect_interval (EV_AX_ interval); 262 ev_set_io_collect_interval (EV_AX_ interval);
238 } 263 }
239 264
240 void set_timeout_collect_interval (tstamp interval) throw () 265 void set_timeout_collect_interval (tstamp interval) throw ()
241 { 266 {
242 ev_set_timeout_collect_interval (EV_AX_ interval); 267 ev_set_timeout_collect_interval (EV_AX_ interval);
243 } 268 }
269#endif
244 270
245 // function callback 271 // function callback
246 void once (int fd, int events, tstamp timeout, void (*cb)(int, void *), void *arg = 0) throw () 272 void once (int fd, int events, tstamp timeout, void (*cb)(int, void *), void *arg = 0) throw ()
247 { 273 {
248 ev_once (EV_AX_ fd, events, timeout, cb, arg); 274 ev_once (EV_AX_ fd, events, timeout, cb, arg);
406 struct base : ev_watcher 432 struct base : ev_watcher
407 { 433 {
408 #if EV_MULTIPLICITY 434 #if EV_MULTIPLICITY
409 EV_PX; 435 EV_PX;
410 436
437 // loop set
411 void set (EV_P) throw () 438 void set (EV_P) throw ()
412 { 439 {
413 this->EV_A = EV_A; 440 this->EV_A = EV_A;
414 } 441 }
415 #endif 442 #endif
471 } 498 }
472 499
473 template<class K, void (K::*method)()> 500 template<class K, void (K::*method)()>
474 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)
475 { 502 {
476 static_cast<K *>(w->data)->*method 503 (static_cast<K *>(w->data)->*method)
477 (); 504 ();
478 } 505 }
479 506
480 void operator ()(int events = EV_UNDEF) 507 void operator ()(int events = EV_UNDEF)
481 { 508 {
635 662
636 void again () throw () 663 void again () throw ()
637 { 664 {
638 ev_timer_again (EV_A_ static_cast<ev_timer *>(this)); 665 ev_timer_again (EV_A_ static_cast<ev_timer *>(this));
639 } 666 }
667
668 ev_tstamp remaining ()
669 {
670 return ev_timer_remaining (EV_A_ static_cast<ev_timer *>(this));
671 }
640 EV_END_WATCHER (timer, timer) 672 EV_END_WATCHER (timer, timer)
641 673
642 #if EV_PERIODIC_ENABLE 674 #if EV_PERIODIC_ENABLE
643 EV_BEGIN_WATCHER (periodic, periodic) 675 EV_BEGIN_WATCHER (periodic, periodic)
644 void set (ev_tstamp at, ev_tstamp interval = 0.) throw () 676 void set (ev_tstamp at, ev_tstamp interval = 0.) throw ()
660 ev_periodic_again (EV_A_ static_cast<ev_periodic *>(this)); 692 ev_periodic_again (EV_A_ static_cast<ev_periodic *>(this));
661 } 693 }
662 EV_END_WATCHER (periodic, periodic) 694 EV_END_WATCHER (periodic, periodic)
663 #endif 695 #endif
664 696
697 #if EV_SIGNAL_ENABLE
665 EV_BEGIN_WATCHER (sig, signal) 698 EV_BEGIN_WATCHER (sig, signal)
666 void set (int signum) throw () 699 void set (int signum) throw ()
667 { 700 {
668 int active = is_active (); 701 int active = is_active ();
669 if (active) stop (); 702 if (active) stop ();
675 { 708 {
676 set (signum); 709 set (signum);
677 start (); 710 start ();
678 } 711 }
679 EV_END_WATCHER (sig, signal) 712 EV_END_WATCHER (sig, signal)
713 #endif
680 714
715 #if EV_CHILD_ENABLE
681 EV_BEGIN_WATCHER (child, child) 716 EV_BEGIN_WATCHER (child, child)
682 void set (int pid, int trace = 0) throw () 717 void set (int pid, int trace = 0) throw ()
683 { 718 {
684 int active = is_active (); 719 int active = is_active ();
685 if (active) stop (); 720 if (active) stop ();
691 { 726 {
692 set (pid, trace); 727 set (pid, trace);
693 start (); 728 start ();
694 } 729 }
695 EV_END_WATCHER (child, child) 730 EV_END_WATCHER (child, child)
731 #endif
696 732
697 #if EV_STAT_ENABLE 733 #if EV_STAT_ENABLE
698 EV_BEGIN_WATCHER (stat, stat) 734 EV_BEGIN_WATCHER (stat, stat)
699 void set (const char *path, ev_tstamp interval = 0.) throw () 735 void set (const char *path, ev_tstamp interval = 0.) throw ()
700 { 736 {
716 ev_stat_stat (EV_A_ static_cast<ev_stat *>(this)); 752 ev_stat_stat (EV_A_ static_cast<ev_stat *>(this));
717 } 753 }
718 EV_END_WATCHER (stat, stat) 754 EV_END_WATCHER (stat, stat)
719 #endif 755 #endif
720 756
757 #if EV_IDLE_ENABLE
721 EV_BEGIN_WATCHER (idle, idle) 758 EV_BEGIN_WATCHER (idle, idle)
722 void set () throw () { } 759 void set () throw () { }
723 EV_END_WATCHER (idle, idle) 760 EV_END_WATCHER (idle, idle)
761 #endif
724 762
763 #if EV_PREPARE_ENABLE
725 EV_BEGIN_WATCHER (prepare, prepare) 764 EV_BEGIN_WATCHER (prepare, prepare)
726 void set () throw () { } 765 void set () throw () { }
727 EV_END_WATCHER (prepare, prepare) 766 EV_END_WATCHER (prepare, prepare)
767 #endif
728 768
769 #if EV_CHECK_ENABLE
729 EV_BEGIN_WATCHER (check, check) 770 EV_BEGIN_WATCHER (check, check)
730 void set () throw () { } 771 void set () throw () { }
731 EV_END_WATCHER (check, check) 772 EV_END_WATCHER (check, check)
773 #endif
732 774
733 #if EV_EMBED_ENABLE 775 #if EV_EMBED_ENABLE
734 EV_BEGIN_WATCHER (embed, embed) 776 EV_BEGIN_WATCHER (embed, embed)
735 void set (struct ev_loop *embedded_loop) throw () 777 void set (struct ev_loop *embedded_loop) throw ()
736 { 778 {
759 EV_END_WATCHER (fork, fork) 801 EV_END_WATCHER (fork, fork)
760 #endif 802 #endif
761 803
762 #if EV_ASYNC_ENABLE 804 #if EV_ASYNC_ENABLE
763 EV_BEGIN_WATCHER (async, async) 805 EV_BEGIN_WATCHER (async, async)
764 void set () throw () { }
765
766 void send () throw () 806 void send () throw ()
767 { 807 {
768 ev_async_send (EV_A_ static_cast<ev_async *>(this)); 808 ev_async_send (EV_A_ static_cast<ev_async *>(this));
769 } 809 }
770 810

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines