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

Comparing libev/ev++.h (file contents):
Revision 1.47 by root, Sat Dec 26 09:21:54 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 {
672 ev_periodic_again (EV_A_ static_cast<ev_periodic *>(this)); 683 ev_periodic_again (EV_A_ static_cast<ev_periodic *>(this));
673 } 684 }
674 EV_END_WATCHER (periodic, periodic) 685 EV_END_WATCHER (periodic, periodic)
675 #endif 686 #endif
676 687
688 #if EV_SIGNAL_ENABLE
677 EV_BEGIN_WATCHER (sig, signal) 689 EV_BEGIN_WATCHER (sig, signal)
678 void set (int signum) throw () 690 void set (int signum) throw ()
679 { 691 {
680 int active = is_active (); 692 int active = is_active ();
681 if (active) stop (); 693 if (active) stop ();
687 { 699 {
688 set (signum); 700 set (signum);
689 start (); 701 start ();
690 } 702 }
691 EV_END_WATCHER (sig, signal) 703 EV_END_WATCHER (sig, signal)
704 #endif
692 705
706 #if EV_CHILD_ENABLE
693 EV_BEGIN_WATCHER (child, child) 707 EV_BEGIN_WATCHER (child, child)
694 void set (int pid, int trace = 0) throw () 708 void set (int pid, int trace = 0) throw ()
695 { 709 {
696 int active = is_active (); 710 int active = is_active ();
697 if (active) stop (); 711 if (active) stop ();
703 { 717 {
704 set (pid, trace); 718 set (pid, trace);
705 start (); 719 start ();
706 } 720 }
707 EV_END_WATCHER (child, child) 721 EV_END_WATCHER (child, child)
722 #endif
708 723
709 #if EV_STAT_ENABLE 724 #if EV_STAT_ENABLE
710 EV_BEGIN_WATCHER (stat, stat) 725 EV_BEGIN_WATCHER (stat, stat)
711 void set (const char *path, ev_tstamp interval = 0.) throw () 726 void set (const char *path, ev_tstamp interval = 0.) throw ()
712 { 727 {
728 ev_stat_stat (EV_A_ static_cast<ev_stat *>(this)); 743 ev_stat_stat (EV_A_ static_cast<ev_stat *>(this));
729 } 744 }
730 EV_END_WATCHER (stat, stat) 745 EV_END_WATCHER (stat, stat)
731 #endif 746 #endif
732 747
733#if EV_IDLE_ENABLE 748 #if EV_IDLE_ENABLE
734 EV_BEGIN_WATCHER (idle, idle) 749 EV_BEGIN_WATCHER (idle, idle)
735 void set () throw () { } 750 void set () throw () { }
736 EV_END_WATCHER (idle, idle) 751 EV_END_WATCHER (idle, idle)
737#endif 752 #endif
738 753
754 #if EV_PREPARE_ENABLE
739 EV_BEGIN_WATCHER (prepare, prepare) 755 EV_BEGIN_WATCHER (prepare, prepare)
740 void set () throw () { } 756 void set () throw () { }
741 EV_END_WATCHER (prepare, prepare) 757 EV_END_WATCHER (prepare, prepare)
758 #endif
742 759
760 #if EV_CHECK_ENABLE
743 EV_BEGIN_WATCHER (check, check) 761 EV_BEGIN_WATCHER (check, check)
744 void set () throw () { } 762 void set () throw () { }
745 EV_END_WATCHER (check, check) 763 EV_END_WATCHER (check, check)
764 #endif
746 765
747 #if EV_EMBED_ENABLE 766 #if EV_EMBED_ENABLE
748 EV_BEGIN_WATCHER (embed, embed) 767 EV_BEGIN_WATCHER (embed, embed)
749 void set (struct ev_loop *embedded_loop) throw () 768 void set (struct ev_loop *embedded_loop) throw ()
750 { 769 {
773 EV_END_WATCHER (fork, fork) 792 EV_END_WATCHER (fork, fork)
774 #endif 793 #endif
775 794
776 #if EV_ASYNC_ENABLE 795 #if EV_ASYNC_ENABLE
777 EV_BEGIN_WATCHER (async, async) 796 EV_BEGIN_WATCHER (async, async)
778 void set () throw () { }
779
780 void send () throw () 797 void send () throw ()
781 { 798 {
782 ev_async_send (EV_A_ static_cast<ev_async *>(this)); 799 ev_async_send (EV_A_ static_cast<ev_async *>(this));
783 } 800 }
784 801

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines