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.32 by root, Sat Jan 19 00:49:06 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 (bad_loop)
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 { 140 {
142#if EV_MULTIPLICIY && EV_CXX_EXCEPTIONS 141#if EV_MULTIPLICITY
143 if (!EV_A) 142 if (!EV_AX)
144 throw bad_loop (); 143 throw bad_loop ();
145#endif 144#endif
146 } 145 }
147 146
148 bool operator== (const loop_ref &other) const throw () 147 bool operator == (const loop_ref &other) const throw ()
149 { 148 {
150#if EV_MULTIPLICITY 149#if EV_MULTIPLICITY
151 return this->EV_AX == other.EV_AX; 150 return EV_AX == other.EV_AX;
152#else 151#else
153 return true; 152 return true;
154#endif 153#endif
155 } 154 }
156 155
157 bool operator!= (const loop_ref &other) const throw () 156 bool operator != (const loop_ref &other) const throw ()
158 { 157 {
159#if EV_MULTIPLICITY 158#if EV_MULTIPLICITY
160 return ! (*this == other); 159 return ! (*this == other);
161#else 160#else
162 return false; 161 return false;
369#endif 368#endif
370 369
371 struct default_loop: loop_ref 370 struct default_loop: loop_ref
372 { 371 {
373 372
374 default_loop (unsigned int flags = AUTO) EV_THROW (bad_loop) 373 default_loop (unsigned int flags = AUTO) throw (bad_loop)
375#if EV_MULTIPLICITY 374#if EV_MULTIPLICITY
376 : loop_ref (ev_default_loop (flags)) 375 : loop_ref (ev_default_loop (flags))
377 { 376#endif
378 } 377 {
379#else 378#ifndef EV_MULTIPLICITY
380 {
381 #if EV_CXX_EXCEPTIONS
382 int r =
383 #endif
384 ev_default_loop (flags); 379 if (!ev_default_loop (flags))
385 #if EV_CXX_EXCEPTIONS
386 if (!r)
387 throw bad_loop (); 380 throw bad_loop ();
388 #endif 381#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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines