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

Comparing libev/ev++.h (file contents):
Revision 1.31 by root, Sat Jan 19 00:39:38 2008 UTC vs.
Revision 1.37 by root, Fri Jan 25 15:45:08 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;
103 { 99 {
104 ONE = EVUNLOOP_ONE, 100 ONE = EVUNLOOP_ONE,
105 ALL = EVUNLOOP_ALL 101 ALL = EVUNLOOP_ALL
106 }; 102 };
107 103
108#if EV_CXX_EXCEPTIONS 104 struct bad_loop
109 struct bad_loop : std::runtime_error 105#if EV_USE_STDEXCEPT
106 : std::runtime_error
107#endif
110 { 108 {
109#if EV_USE_STDEXCEPT
111 bad_loop () 110 bad_loop ()
112 : std::runtime_error ("loop can't be initialized") 111 : std::runtime_error ("libev event loop cannot be initialized, bad value of LIBEV_FLAGS?")
113 {
114 } 112 {
115 }; 113 }
116#endif 114#endif
115 };
117 116
118#ifdef EV_AX 117#ifdef EV_AX
119# undef EV_AX 118# undef EV_AX
120#endif 119#endif
121 120
132#endif 131#endif
133 132
134 struct loop_ref 133 struct loop_ref
135 { 134 {
136 135
137 loop_ref (EV_P) 136 loop_ref (EV_P) throw ()
138#if EV_MULTIPLICITY 137#if EV_MULTIPLICITY
139 EV_THROW (bad_loop) : EV_AX (EV_A) 138 : EV_AX (EV_A)
140#endif 139#endif
141 {
142#if EV_MULTIPLICIY && EV_CXX_EXCEPTIONS
143 if (!EV_A)
144 throw bad_loop ();
145#endif
146 } 140 {
141 }
147 142
148 bool operator== (const loop_ref &other) const throw () 143 bool operator == (const loop_ref &other) const throw ()
149 { 144 {
150#if EV_MULTIPLICITY 145#if EV_MULTIPLICITY
151 return this->EV_AX == other.EV_AX; 146 return EV_AX == other.EV_AX;
152#else 147#else
153 return true; 148 return true;
154#endif 149#endif
155 } 150 }
156 151
157 bool operator!= (const loop_ref &other) const throw () 152 bool operator != (const loop_ref &other) const throw ()
158 { 153 {
159#if EV_MULTIPLICITY 154#if EV_MULTIPLICITY
160 return ! (*this == other); 155 return ! (*this == other);
161#else 156#else
162 return false; 157 return false;
163#endif 158#endif
164 } 159 }
165 160
166#if EV_MULTIPLICITY 161#if EV_MULTIPLICITY
167 bool operator== (struct ev_loop *other) const throw () 162 bool operator == (struct ev_loop *other) const throw ()
168 { 163 {
169 return this->EV_AX == other; 164 return this->EV_AX == other;
170 } 165 }
171 166
172 bool operator!= (struct ev_loop *other) const throw () 167 bool operator != (struct ev_loop *other) const throw ()
173 { 168 {
174 return ! (*this == other); 169 return ! (*this == other);
175 } 170 }
176 171
177 bool operator== (const struct ev_loop *other) const throw () 172 bool operator == (const struct ev_loop *other) const throw ()
178 { 173 {
179 return this->EV_AX == other; 174 return this->EV_AX == other;
180 } 175 }
181 176
182 bool operator!= (const struct ev_loop *other) const throw () 177 bool operator != (const struct ev_loop *other) const throw ()
183 { 178 {
184 return (*this == other); 179 return (*this == other);
185 } 180 }
186 181
187 operator struct ev_loop * () const throw () 182 operator struct ev_loop * () const throw ()
343#endif 338#endif
344 339
345 }; 340 };
346 341
347#if EV_MULTIPLICITY 342#if EV_MULTIPLICITY
348 struct dynamic_loop: loop_ref 343 struct dynamic_loop : loop_ref
349 { 344 {
350 345
351 dynamic_loop (unsigned int flags = AUTO) EV_THROW (bad_loop) 346 dynamic_loop (unsigned int flags = AUTO) throw (bad_loop)
352 : loop_ref (ev_loop_new (flags)) 347 : loop_ref (ev_loop_new (flags))
353 { 348 {
349 if (!EV_AX)
350 throw bad_loop ();
354 } 351 }
355 352
356 ~dynamic_loop () throw () 353 ~dynamic_loop () throw ()
357 { 354 {
358 ev_loop_destroy (EV_AX); 355 ev_loop_destroy (EV_AX);
366 dynamic_loop & operator= (const dynamic_loop &); 363 dynamic_loop & operator= (const dynamic_loop &);
367 364
368 }; 365 };
369#endif 366#endif
370 367
371 struct default_loop: loop_ref 368 struct default_loop : loop_ref
372 { 369 {
373 370
374 default_loop (unsigned int flags = AUTO) EV_THROW (bad_loop) 371 default_loop (unsigned int flags = AUTO) throw (bad_loop)
375#if EV_MULTIPLICITY 372#if EV_MULTIPLICITY
376 : loop_ref (ev_default_loop (flags)) 373 : loop_ref (ev_default_loop (flags))
377 { 374#endif
378 } 375 {
376 if (
377#if EV_MULTIPLICITY
378 !EV_AX
379#else 379#else
380 {
381 #if EV_CXX_EXCEPTIONS
382 int r =
383 #endif
384 ev_default_loop (flags); 380 !ev_default_loop (flags)
385 #if EV_CXX_EXCEPTIONS 381#endif
386 if (!r) 382 )
387 throw bad_loop (); 383 throw bad_loop ();
388 #endif
389 } 384 }
390#endif
391 385
392 ~default_loop () throw () 386 ~default_loop () throw ()
393 { 387 {
394 ev_default_destroy (); 388 ev_default_destroy ();
395#if EV_MULTIPLICITY
396 EV_AX = 0;
397#endif
398 } 389 }
399 390
400 private: 391 private:
401
402 default_loop (const default_loop &); 392 default_loop (const default_loop &);
403
404 default_loop & operator= (const default_loop &); 393 default_loop &operator = (const default_loop &);
405
406 }; 394 };
407 395
408 inline loop_ref get_default_loop () throw () 396 inline loop_ref get_default_loop () throw ()
409 { 397 {
410#if EV_MULTIPLICITY 398#if EV_MULTIPLICITY
707 start (); 695 start ();
708 } 696 }
709 EV_END_WATCHER (sig, signal) 697 EV_END_WATCHER (sig, signal)
710 698
711 EV_BEGIN_WATCHER (child, child) 699 EV_BEGIN_WATCHER (child, child)
712 void set (int pid) throw () 700 void set (int pid, int trace = 0) throw ()
713 { 701 {
714 int active = is_active (); 702 int active = is_active ();
715 if (active) stop (); 703 if (active) stop ();
716 ev_child_set (static_cast<ev_child *>(this), pid); 704 ev_child_set (static_cast<ev_child *>(this), pid, trace);
717 if (active) start (); 705 if (active) start ();
718 } 706 }
719 707
720 void start (int pid) throw () 708 void start (int pid, int trace = 0) throw ()
721 { 709 {
722 set (pid); 710 set (pid, trace);
723 start (); 711 start ();
724 } 712 }
725 EV_END_WATCHER (child, child) 713 EV_END_WATCHER (child, child)
726 714
727 #if EV_STAT_ENABLE 715 #if EV_STAT_ENABLE
788 #undef EV_BEGIN_WATCHER 776 #undef EV_BEGIN_WATCHER
789 #undef EV_END_WATCHER 777 #undef EV_END_WATCHER
790 778
791} 779}
792 780
793#undef EV_THROW
794
795#endif 781#endif
796 782

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines