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.38 by root, Mon Jan 28 11:43:37 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
131# define EV_AX_ 130# define EV_AX_
132#endif 131#endif
133 132
134 struct loop_ref 133 struct loop_ref
135 { 134 {
136
137 loop_ref (EV_P) 135 loop_ref (EV_P) throw ()
138#if EV_MULTIPLICITY 136#if EV_MULTIPLICITY
139 EV_THROW (bad_loop) : EV_AX (EV_A) 137 : EV_AX (EV_A)
140#endif 138#endif
141 {
142#if EV_MULTIPLICIY && EV_CXX_EXCEPTIONS
143 if (!EV_A)
144 throw bad_loop ();
145#endif
146 } 139 {
140 }
147 141
148 bool operator== (const loop_ref &other) const throw () 142 bool operator == (const loop_ref &other) const throw ()
149 { 143 {
150#if EV_MULTIPLICITY 144#if EV_MULTIPLICITY
151 return this->EV_AX == other.EV_AX; 145 return EV_AX == other.EV_AX;
152#else 146#else
153 return true; 147 return true;
154#endif 148#endif
155 } 149 }
156 150
157 bool operator!= (const loop_ref &other) const throw () 151 bool operator != (const loop_ref &other) const throw ()
158 { 152 {
159#if EV_MULTIPLICITY 153#if EV_MULTIPLICITY
160 return ! (*this == other); 154 return ! (*this == other);
161#else 155#else
162 return false; 156 return false;
163#endif 157#endif
164 } 158 }
165 159
166#if EV_MULTIPLICITY 160#if EV_MULTIPLICITY
167 bool operator== (struct ev_loop *other) const throw () 161 bool operator == (struct ev_loop *other) const throw ()
168 { 162 {
169 return this->EV_AX == other; 163 return this->EV_AX == other;
170 } 164 }
171 165
172 bool operator!= (struct ev_loop *other) const throw () 166 bool operator != (struct ev_loop *other) const throw ()
173 { 167 {
174 return ! (*this == other); 168 return ! (*this == other);
175 } 169 }
176 170
177 bool operator== (const struct ev_loop *other) const throw () 171 bool operator == (const struct ev_loop *other) const throw ()
178 { 172 {
179 return this->EV_AX == other; 173 return this->EV_AX == other;
180 } 174 }
181 175
182 bool operator!= (const struct ev_loop *other) const throw () 176 bool operator != (const struct ev_loop *other) const throw ()
183 { 177 {
184 return (*this == other); 178 return (*this == other);
185 } 179 }
186 180
187 operator struct ev_loop * () const throw () 181 operator struct ev_loop * () const throw ()
343#endif 337#endif
344 338
345 }; 339 };
346 340
347#if EV_MULTIPLICITY 341#if EV_MULTIPLICITY
348 struct dynamic_loop: loop_ref 342 struct dynamic_loop : loop_ref
349 { 343 {
350 344
351 dynamic_loop (unsigned int flags = AUTO) EV_THROW (bad_loop) 345 dynamic_loop (unsigned int flags = AUTO) throw (bad_loop)
352 : loop_ref (ev_loop_new (flags)) 346 : loop_ref (ev_loop_new (flags))
353 { 347 {
348 if (!EV_AX)
349 throw bad_loop ();
354 } 350 }
355 351
356 ~dynamic_loop () throw () 352 ~dynamic_loop () throw ()
357 { 353 {
358 ev_loop_destroy (EV_AX); 354 ev_loop_destroy (EV_AX);
366 dynamic_loop & operator= (const dynamic_loop &); 362 dynamic_loop & operator= (const dynamic_loop &);
367 363
368 }; 364 };
369#endif 365#endif
370 366
371 struct default_loop: loop_ref 367 struct default_loop : loop_ref
372 { 368 {
373
374 default_loop (unsigned int flags = AUTO) EV_THROW (bad_loop) 369 default_loop (unsigned int flags = AUTO) throw (bad_loop)
375#if EV_MULTIPLICITY 370#if EV_MULTIPLICITY
376 : loop_ref (ev_default_loop (flags)) 371 : loop_ref (ev_default_loop (flags))
377 { 372#endif
378 } 373 {
374 if (
375#if EV_MULTIPLICITY
376 !EV_AX
379#else 377#else
380 {
381 #if EV_CXX_EXCEPTIONS
382 int r =
383 #endif
384 ev_default_loop (flags); 378 !ev_default_loop (flags)
385 #if EV_CXX_EXCEPTIONS 379#endif
386 if (!r) 380 )
387 throw bad_loop (); 381 throw bad_loop ();
388 #endif
389 } 382 }
390#endif
391 383
392 ~default_loop () throw () 384 ~default_loop () throw ()
393 { 385 {
394 ev_default_destroy (); 386 ev_default_destroy ();
395#if EV_MULTIPLICITY
396 EV_AX = 0;
397#endif
398 } 387 }
399 388
400 private: 389 private:
401
402 default_loop (const default_loop &); 390 default_loop (const default_loop &);
403
404 default_loop & operator= (const default_loop &); 391 default_loop &operator = (const default_loop &);
405
406 }; 392 };
407 393
408 inline loop_ref get_default_loop () throw () 394 inline loop_ref get_default_loop () throw ()
409 { 395 {
410#if EV_MULTIPLICITY 396#if EV_MULTIPLICITY
707 start (); 693 start ();
708 } 694 }
709 EV_END_WATCHER (sig, signal) 695 EV_END_WATCHER (sig, signal)
710 696
711 EV_BEGIN_WATCHER (child, child) 697 EV_BEGIN_WATCHER (child, child)
712 void set (int pid) throw () 698 void set (int pid, int trace = 0) throw ()
713 { 699 {
714 int active = is_active (); 700 int active = is_active ();
715 if (active) stop (); 701 if (active) stop ();
716 ev_child_set (static_cast<ev_child *>(this), pid); 702 ev_child_set (static_cast<ev_child *>(this), pid, trace);
717 if (active) start (); 703 if (active) start ();
718 } 704 }
719 705
720 void start (int pid) throw () 706 void start (int pid, int trace = 0) throw ()
721 { 707 {
722 set (pid); 708 set (pid, trace);
723 start (); 709 start ();
724 } 710 }
725 EV_END_WATCHER (child, child) 711 EV_END_WATCHER (child, child)
726 712
727 #if EV_STAT_ENABLE 713 #if EV_STAT_ENABLE
785 #undef EV_PX 771 #undef EV_PX
786 #undef EV_PX_ 772 #undef EV_PX_
787 #undef EV_CONSTRUCT 773 #undef EV_CONSTRUCT
788 #undef EV_BEGIN_WATCHER 774 #undef EV_BEGIN_WATCHER
789 #undef EV_END_WATCHER 775 #undef EV_END_WATCHER
790
791} 776}
792 777
793#undef EV_THROW
794
795#endif 778#endif
796 779

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines