… | |
… | |
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 | |
61 | namespace ev { |
57 | namespace 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 | }; |
112 | { |
|
|
113 | } |
114 | #endif |
114 | #endif |
|
|
115 | }; |
115 | |
116 | |
116 | #ifdef EV_AX |
117 | #ifdef EV_AX |
117 | # undef EV_AX |
118 | # undef EV_AX |
118 | #endif |
119 | #endif |
119 | |
120 | |
… | |
… | |
132 | struct loop_ref |
133 | struct loop_ref |
133 | { |
134 | { |
134 | |
135 | |
135 | loop_ref (EV_P) |
136 | loop_ref (EV_P) |
136 | #if EV_MULTIPLICITY |
137 | #if EV_MULTIPLICITY |
137 | EV_THROW (bad_loop) : EV_AX (EV_A) |
138 | throw (bad_loop) : EV_AX (EV_A) |
138 | #endif |
|
|
139 | { |
139 | { |
140 | #if EV_MULTIPLICIY && EV_CXX_EXCEPTIONS |
|
|
141 | if (!EV_A) |
140 | if (!EV_AX) |
142 | throw bad_loop (); |
141 | throw bad_loop (); |
143 | #endif |
142 | } |
|
|
143 | #else |
|
|
144 | throw () |
144 | } |
145 | { |
|
|
146 | } |
|
|
147 | #endif |
145 | |
148 | |
146 | bool operator== (const loop_ref &other) const EV_THROW () |
149 | bool operator == (const loop_ref &other) const throw () |
147 | { |
150 | { |
148 | #if EV_MULTIPLICITY |
151 | #if EV_MULTIPLICITY |
149 | return this->EV_AX == other.EV_AX; |
152 | return EV_AX == other.EV_AX; |
150 | #else |
153 | #else |
151 | return true; |
154 | return true; |
152 | #endif |
155 | #endif |
153 | } |
156 | } |
154 | |
157 | |
155 | bool operator!= (const loop_ref &other) const EV_THROW () |
158 | bool operator != (const loop_ref &other) const throw () |
156 | { |
159 | { |
157 | #if EV_MULTIPLICITY |
160 | #if EV_MULTIPLICITY |
158 | return ! (*this == other); |
161 | return ! (*this == other); |
159 | #else |
162 | #else |
160 | return false; |
163 | return false; |
161 | #endif |
164 | #endif |
162 | } |
165 | } |
163 | |
166 | |
164 | #if EV_MULTIPLICITY |
167 | #if EV_MULTIPLICITY |
165 | bool operator== (struct ev_loop *other) const EV_THROW () |
168 | bool operator== (struct ev_loop *other) const throw () |
166 | { |
169 | { |
167 | return this->EV_AX == other; |
170 | return this->EV_AX == other; |
168 | } |
171 | } |
169 | |
172 | |
170 | bool operator!= (struct ev_loop *other) const EV_THROW () |
173 | bool operator!= (struct ev_loop *other) const throw () |
171 | { |
174 | { |
172 | return ! (*this == other); |
175 | return ! (*this == other); |
173 | } |
176 | } |
174 | |
177 | |
175 | bool operator== (const struct ev_loop *other) const EV_THROW () |
178 | bool operator== (const struct ev_loop *other) const throw () |
176 | { |
179 | { |
177 | return this->EV_AX == other; |
180 | return this->EV_AX == other; |
178 | } |
181 | } |
179 | |
182 | |
180 | bool operator!= (const struct ev_loop *other) const EV_THROW () |
183 | bool operator!= (const struct ev_loop *other) const throw () |
181 | { |
184 | { |
182 | return (*this == other); |
185 | return (*this == other); |
183 | } |
186 | } |
184 | |
187 | |
185 | operator struct ev_loop * () const EV_THROW () |
188 | operator struct ev_loop * () const throw () |
186 | { |
189 | { |
187 | return EV_AX; |
190 | return EV_AX; |
188 | } |
191 | } |
189 | |
192 | |
190 | operator const struct ev_loop * () const EV_THROW () |
193 | operator const struct ev_loop * () const throw () |
191 | { |
194 | { |
192 | return EV_AX; |
195 | return EV_AX; |
193 | } |
196 | } |
194 | |
197 | |
195 | bool is_default () const EV_THROW () |
198 | bool is_default () const throw () |
196 | { |
199 | { |
197 | return EV_AX == ev_default_loop (0); |
200 | return EV_AX == ev_default_loop (0); |
198 | } |
201 | } |
199 | #endif |
202 | #endif |
200 | |
203 | |
201 | void loop (int flags = 0) |
204 | void loop (int flags = 0) |
202 | { |
205 | { |
203 | ev_loop (EV_AX_ flags); |
206 | ev_loop (EV_AX_ flags); |
204 | } |
207 | } |
205 | |
208 | |
206 | void unloop (how_t how = ONE) EV_THROW () |
209 | void unloop (how_t how = ONE) throw () |
207 | { |
210 | { |
208 | ev_unloop (EV_AX_ how); |
211 | ev_unloop (EV_AX_ how); |
209 | } |
212 | } |
210 | |
213 | |
211 | void post_fork () EV_THROW () |
214 | void post_fork () throw () |
212 | { |
215 | { |
213 | #if EV_MULTIPLICITY |
216 | #if EV_MULTIPLICITY |
214 | ev_loop_fork (EV_AX); |
217 | ev_loop_fork (EV_AX); |
215 | #else |
218 | #else |
216 | ev_default_fork (); |
219 | ev_default_fork (); |
217 | #endif |
220 | #endif |
218 | } |
221 | } |
219 | |
222 | |
220 | unsigned int count () const EV_THROW () |
223 | unsigned int count () const throw () |
221 | { |
224 | { |
222 | return ev_loop_count (EV_AX); |
225 | return ev_loop_count (EV_AX); |
223 | } |
226 | } |
224 | |
227 | |
225 | unsigned int backend () const EV_THROW () |
228 | unsigned int backend () const throw () |
226 | { |
229 | { |
227 | return ev_backend (EV_AX); |
230 | return ev_backend (EV_AX); |
228 | } |
231 | } |
229 | |
232 | |
230 | tstamp now () const EV_THROW () |
233 | tstamp now () const throw () |
231 | { |
234 | { |
232 | return ev_now (EV_AX); |
235 | return ev_now (EV_AX); |
233 | } |
236 | } |
234 | |
237 | |
235 | void ref () EV_THROW () |
238 | void ref () throw () |
236 | { |
239 | { |
237 | ev_ref (EV_AX); |
240 | ev_ref (EV_AX); |
238 | } |
241 | } |
239 | |
242 | |
240 | void unref () EV_THROW () |
243 | void unref () throw () |
241 | { |
244 | { |
242 | ev_unref (EV_AX); |
245 | ev_unref (EV_AX); |
243 | } |
246 | } |
244 | |
247 | |
245 | void set_io_collect_interval (tstamp interval) EV_THROW () |
248 | void set_io_collect_interval (tstamp interval) throw () |
246 | { |
249 | { |
247 | ev_set_io_collect_interval (EV_AX_ interval); |
250 | ev_set_io_collect_interval (EV_AX_ interval); |
248 | } |
251 | } |
249 | |
252 | |
250 | void set_timeout_collect_interval (tstamp interval) EV_THROW () |
253 | void set_timeout_collect_interval (tstamp interval) throw () |
251 | { |
254 | { |
252 | ev_set_timeout_collect_interval (EV_AX_ interval); |
255 | ev_set_timeout_collect_interval (EV_AX_ interval); |
253 | } |
256 | } |
254 | |
257 | |
255 | // function callback |
258 | // function callback |
256 | void once (int fd, int events, tstamp timeout, void (*cb)(int, void *), void* arg = 0) EV_THROW () |
259 | void once (int fd, int events, tstamp timeout, void (*cb)(int, void *), void* arg = 0) throw () |
257 | { |
260 | { |
258 | ev_once (EV_AX_ fd, events, timeout, cb, arg); |
261 | ev_once (EV_AX_ fd, events, timeout, cb, arg); |
259 | } |
262 | } |
260 | |
263 | |
261 | // method callback |
264 | // method callback |
262 | template<class K, void (K::*method)(int)> |
265 | template<class K, void (K::*method)(int)> |
263 | void once (int fd, int events, tstamp timeout, K *object) EV_THROW () |
266 | void once (int fd, int events, tstamp timeout, K *object) throw () |
264 | { |
267 | { |
265 | once (fd, events, timeout, method_thunk<K, method>, object); |
268 | once (fd, events, timeout, method_thunk<K, method>, object); |
266 | } |
269 | } |
267 | |
270 | |
268 | template<class K, void (K::*method)(int)> |
271 | template<class K, void (K::*method)(int)> |
… | |
… | |
272 | (obj->*method) (revents); |
275 | (obj->*method) (revents); |
273 | } |
276 | } |
274 | |
277 | |
275 | // const method callback |
278 | // const method callback |
276 | template<class K, void (K::*method)(int) const> |
279 | template<class K, void (K::*method)(int) const> |
277 | void once (int fd, int events, tstamp timeout, const K *object) EV_THROW () |
280 | void once (int fd, int events, tstamp timeout, const K *object) throw () |
278 | { |
281 | { |
279 | once (fd, events, timeout, const_method_thunk<K, method>, object); |
282 | once (fd, events, timeout, const_method_thunk<K, method>, object); |
280 | } |
283 | } |
281 | |
284 | |
282 | template<class K, void (K::*method)(int) const> |
285 | template<class K, void (K::*method)(int) const> |
… | |
… | |
286 | (obj->*method) (revents); |
289 | (obj->*method) (revents); |
287 | } |
290 | } |
288 | |
291 | |
289 | // simple method callback |
292 | // simple method callback |
290 | template<class K, void (K::*method)()> |
293 | template<class K, void (K::*method)()> |
291 | void once (int fd, int events, tstamp timeout, K *object) EV_THROW () |
294 | void once (int fd, int events, tstamp timeout, K *object) throw () |
292 | { |
295 | { |
293 | once (fd, events, timeout, method_noargs_thunk<K, method>, object); |
296 | once (fd, events, timeout, method_noargs_thunk<K, method>, object); |
294 | } |
297 | } |
295 | |
298 | |
296 | template<class K, void (K::*method)()> |
299 | template<class K, void (K::*method)()> |
… | |
… | |
300 | (obj->*method) (); |
303 | (obj->*method) (); |
301 | } |
304 | } |
302 | |
305 | |
303 | // simpler function callback |
306 | // simpler function callback |
304 | template<void (*cb)(int)> |
307 | template<void (*cb)(int)> |
305 | void once (int fd, int events, tstamp timeout) EV_THROW () |
308 | void once (int fd, int events, tstamp timeout) throw () |
306 | { |
309 | { |
307 | once (fd, events, timeout, simpler_func_thunk<cb>); |
310 | once (fd, events, timeout, simpler_func_thunk<cb>); |
308 | } |
311 | } |
309 | |
312 | |
310 | template<void (*cb)(int)> |
313 | template<void (*cb)(int)> |
… | |
… | |
313 | (*cb) (revents); |
316 | (*cb) (revents); |
314 | } |
317 | } |
315 | |
318 | |
316 | // simplest function callback |
319 | // simplest function callback |
317 | template<void (*cb)()> |
320 | template<void (*cb)()> |
318 | void once (int fd, int events, tstamp timeout) EV_THROW () |
321 | void once (int fd, int events, tstamp timeout) throw () |
319 | { |
322 | { |
320 | once (fd, events, timeout, simplest_func_thunk<cb>); |
323 | once (fd, events, timeout, simplest_func_thunk<cb>); |
321 | } |
324 | } |
322 | |
325 | |
323 | template<void (*cb)()> |
326 | template<void (*cb)()> |
324 | static void simplest_func_thunk (int revents, void* arg) |
327 | static void simplest_func_thunk (int revents, void* arg) |
325 | { |
328 | { |
326 | (*cb) (); |
329 | (*cb) (); |
327 | } |
330 | } |
328 | |
331 | |
329 | void feed_fd_event (int fd, int revents) EV_THROW () |
332 | void feed_fd_event (int fd, int revents) throw () |
330 | { |
333 | { |
331 | ev_feed_fd_event (EV_AX_ fd, revents); |
334 | ev_feed_fd_event (EV_AX_ fd, revents); |
332 | } |
335 | } |
333 | |
336 | |
334 | void feed_signal_event (int signum) EV_THROW () |
337 | void feed_signal_event (int signum) throw () |
335 | { |
338 | { |
336 | ev_feed_signal_event (EV_AX_ signum); |
339 | ev_feed_signal_event (EV_AX_ signum); |
337 | } |
340 | } |
338 | |
341 | |
339 | #if EV_MULTIPLICITY |
342 | #if EV_MULTIPLICITY |
… | |
… | |
344 | |
347 | |
345 | #if EV_MULTIPLICITY |
348 | #if EV_MULTIPLICITY |
346 | struct dynamic_loop: loop_ref |
349 | struct dynamic_loop: loop_ref |
347 | { |
350 | { |
348 | |
351 | |
349 | dynamic_loop (unsigned int flags = AUTO) EV_THROW (bad_loop) |
352 | dynamic_loop (unsigned int flags = AUTO) throw (bad_loop) |
350 | : loop_ref (ev_loop_new (flags)) |
353 | : loop_ref (ev_loop_new (flags)) |
351 | { |
354 | { |
352 | } |
355 | } |
353 | |
356 | |
354 | ~dynamic_loop () EV_THROW () |
357 | ~dynamic_loop () throw () |
355 | { |
358 | { |
356 | ev_loop_destroy (EV_AX); |
359 | ev_loop_destroy (EV_AX); |
357 | EV_AX = 0; |
360 | EV_AX = 0; |
358 | } |
361 | } |
359 | |
362 | |
… | |
… | |
367 | #endif |
370 | #endif |
368 | |
371 | |
369 | struct default_loop: loop_ref |
372 | struct default_loop: loop_ref |
370 | { |
373 | { |
371 | |
374 | |
372 | default_loop (unsigned int flags = AUTO) EV_THROW (bad_loop) |
375 | default_loop (unsigned int flags = AUTO) throw (bad_loop) |
373 | #if EV_MULTIPLICITY |
376 | #if EV_MULTIPLICITY |
374 | : loop_ref (ev_default_loop (flags)) |
377 | : loop_ref (ev_default_loop (flags)) |
375 | { |
378 | #endif |
376 | } |
379 | { |
377 | #else |
380 | #ifndef EV_MULTIPLICITY |
378 | { |
|
|
379 | #if EV_CXX_EXCEPTIONS |
|
|
380 | int r = |
|
|
381 | #endif |
|
|
382 | ev_default_loop (flags); |
381 | if (!ev_default_loop (flags)) |
383 | #if EV_CXX_EXCEPTIONS |
|
|
384 | if (!r) |
|
|
385 | throw bad_loop (); |
382 | throw bad_loop (); |
386 | #endif |
383 | #endif |
387 | } |
384 | } |
388 | #endif |
|
|
389 | |
385 | |
390 | ~default_loop () EV_THROW () |
386 | ~default_loop () throw () |
391 | { |
387 | { |
392 | ev_default_destroy (); |
388 | ev_default_destroy (); |
393 | #if EV_MULTIPLICITY |
|
|
394 | EV_AX = 0; |
|
|
395 | #endif |
|
|
396 | } |
389 | } |
397 | |
390 | |
398 | private: |
391 | private: |
399 | |
|
|
400 | default_loop (const default_loop &); |
392 | default_loop (const default_loop &); |
401 | |
|
|
402 | default_loop & operator= (const default_loop &); |
393 | default_loop &operator = (const default_loop &); |
403 | |
|
|
404 | }; |
394 | }; |
405 | |
395 | |
406 | inline loop_ref get_default_loop () EV_THROW () |
396 | inline loop_ref get_default_loop () throw () |
407 | { |
397 | { |
408 | #if EV_MULTIPLICITY |
398 | #if EV_MULTIPLICITY |
409 | return ev_default_loop (0); |
399 | return ev_default_loop (0); |
410 | #else |
400 | #else |
411 | return loop_ref (); |
401 | return loop_ref (); |
… | |
… | |
429 | struct base : ev_watcher |
419 | struct base : ev_watcher |
430 | { |
420 | { |
431 | #if EV_MULTIPLICITY |
421 | #if EV_MULTIPLICITY |
432 | EV_PX; |
422 | EV_PX; |
433 | |
423 | |
434 | void set (EV_PX) EV_THROW () |
424 | void set (EV_PX) throw () |
435 | { |
425 | { |
436 | this->EV_A = EV_A; |
426 | this->EV_A = EV_A; |
437 | } |
427 | } |
438 | #endif |
428 | #endif |
439 | |
429 | |
440 | base (EV_PX) EV_THROW () |
430 | base (EV_PX) throw () |
441 | #if EV_MULTIPLICITY |
431 | #if EV_MULTIPLICITY |
442 | : EV_A (EV_A) |
432 | : EV_A (EV_A) |
443 | #endif |
433 | #endif |
444 | { |
434 | { |
445 | ev_init (this, 0); |
435 | ev_init (this, 0); |
446 | } |
436 | } |
447 | |
437 | |
448 | void set_ (void *data, void (*cb)(EV_P_ ev_watcher *w, int revents)) EV_THROW () |
438 | void set_ (void *data, void (*cb)(EV_P_ ev_watcher *w, int revents)) throw () |
449 | { |
439 | { |
450 | this->data = data; |
440 | this->data = data; |
451 | ev_set_cb (static_cast<ev_watcher *>(this), cb); |
441 | ev_set_cb (static_cast<ev_watcher *>(this), cb); |
452 | } |
442 | } |
453 | |
443 | |
454 | // method callback |
444 | // method callback |
455 | template<class K, void (K::*method)(watcher &w, int)> |
445 | template<class K, void (K::*method)(watcher &w, int)> |
456 | void set (K *object) EV_THROW () |
446 | void set (K *object) throw () |
457 | { |
447 | { |
458 | set_ (object, method_thunk<K, method>); |
448 | set_ (object, method_thunk<K, method>); |
459 | } |
449 | } |
460 | |
450 | |
461 | template<class K, void (K::*method)(watcher &w, int)> |
451 | template<class K, void (K::*method)(watcher &w, int)> |
… | |
… | |
465 | (obj->*method) (*static_cast<watcher *>(w), revents); |
455 | (obj->*method) (*static_cast<watcher *>(w), revents); |
466 | } |
456 | } |
467 | |
457 | |
468 | // const method callback |
458 | // const method callback |
469 | template<class K, void (K::*method)(watcher &w, int) const> |
459 | template<class K, void (K::*method)(watcher &w, int) const> |
470 | void set (const K *object) EV_THROW () |
460 | void set (const K *object) throw () |
471 | { |
461 | { |
472 | set_ (object, const_method_thunk<K, method>); |
462 | set_ (object, const_method_thunk<K, method>); |
473 | } |
463 | } |
474 | |
464 | |
475 | template<class K, void (K::*method)(watcher &w, int) const> |
465 | template<class K, void (K::*method)(watcher &w, int) const> |
… | |
… | |
479 | (static_cast<K *>(w->data)->*method) (*static_cast<watcher *>(w), revents); |
469 | (static_cast<K *>(w->data)->*method) (*static_cast<watcher *>(w), revents); |
480 | } |
470 | } |
481 | |
471 | |
482 | // function callback |
472 | // function callback |
483 | template<void (*function)(watcher &w, int)> |
473 | template<void (*function)(watcher &w, int)> |
484 | void set (void *data = 0) EV_THROW () |
474 | void set (void *data = 0) throw () |
485 | { |
475 | { |
486 | set_ (data, function_thunk<function>); |
476 | set_ (data, function_thunk<function>); |
487 | } |
477 | } |
488 | |
478 | |
489 | template<void (*function)(watcher &w, int)> |
479 | template<void (*function)(watcher &w, int)> |
… | |
… | |
492 | function (*static_cast<watcher *>(w), revents); |
482 | function (*static_cast<watcher *>(w), revents); |
493 | } |
483 | } |
494 | |
484 | |
495 | // simple callback |
485 | // simple callback |
496 | template<class K, void (K::*method)()> |
486 | template<class K, void (K::*method)()> |
497 | void set (K *object) EV_THROW () |
487 | void set (K *object) throw () |
498 | { |
488 | { |
499 | set_ (object, method_noargs_thunk<K, method>); |
489 | set_ (object, method_noargs_thunk<K, method>); |
500 | } |
490 | } |
501 | |
491 | |
502 | template<class K, void (K::*method)()> |
492 | template<class K, void (K::*method)()> |
… | |
… | |
510 | { |
500 | { |
511 | return ev_cb (static_cast<ev_watcher *>(this)) |
501 | return ev_cb (static_cast<ev_watcher *>(this)) |
512 | (static_cast<ev_watcher *>(this), events); |
502 | (static_cast<ev_watcher *>(this), events); |
513 | } |
503 | } |
514 | |
504 | |
515 | bool is_active () const EV_THROW () |
505 | bool is_active () const throw () |
516 | { |
506 | { |
517 | return ev_is_active (static_cast<const ev_watcher *>(this)); |
507 | return ev_is_active (static_cast<const ev_watcher *>(this)); |
518 | } |
508 | } |
519 | |
509 | |
520 | bool is_pending () const EV_THROW () |
510 | bool is_pending () const throw () |
521 | { |
511 | { |
522 | return ev_is_pending (static_cast<const ev_watcher *>(this)); |
512 | return ev_is_pending (static_cast<const ev_watcher *>(this)); |
523 | } |
513 | } |
524 | |
514 | |
525 | void feed_event (int revents) EV_THROW () |
515 | void feed_event (int revents) throw () |
526 | { |
516 | { |
527 | ev_feed_event (EV_A_ static_cast<const ev_watcher *>(this), revents); |
517 | ev_feed_event (EV_A_ static_cast<const ev_watcher *>(this), revents); |
528 | } |
518 | } |
529 | }; |
519 | }; |
530 | |
520 | |
531 | inline tstamp now () EV_THROW () |
521 | inline tstamp now () throw () |
532 | { |
522 | { |
533 | return ev_time (); |
523 | return ev_time (); |
534 | } |
524 | } |
535 | |
525 | |
536 | inline void delay (tstamp interval) EV_THROW () |
526 | inline void delay (tstamp interval) throw () |
537 | { |
527 | { |
538 | ev_sleep (interval); |
528 | ev_sleep (interval); |
539 | } |
529 | } |
540 | |
530 | |
541 | inline int version_major () EV_THROW () |
531 | inline int version_major () throw () |
542 | { |
532 | { |
543 | return ev_version_major (); |
533 | return ev_version_major (); |
544 | } |
534 | } |
545 | |
535 | |
546 | inline int version_minor () EV_THROW () |
536 | inline int version_minor () throw () |
547 | { |
537 | { |
548 | return ev_version_minor (); |
538 | return ev_version_minor (); |
549 | } |
539 | } |
550 | |
540 | |
551 | inline unsigned int supported_backends () EV_THROW () |
541 | inline unsigned int supported_backends () throw () |
552 | { |
542 | { |
553 | return ev_supported_backends (); |
543 | return ev_supported_backends (); |
554 | } |
544 | } |
555 | |
545 | |
556 | inline unsigned int recommended_backends () EV_THROW () |
546 | inline unsigned int recommended_backends () throw () |
557 | { |
547 | { |
558 | return ev_recommended_backends (); |
548 | return ev_recommended_backends (); |
559 | } |
549 | } |
560 | |
550 | |
561 | inline unsigned int embeddable_backends () EV_THROW () |
551 | inline unsigned int embeddable_backends () throw () |
562 | { |
552 | { |
563 | return ev_embeddable_backends (); |
553 | return ev_embeddable_backends (); |
564 | } |
554 | } |
565 | |
555 | |
566 | inline void set_allocator (void *(*cb)(void *ptr, long size)) EV_THROW () |
556 | inline void set_allocator (void *(*cb)(void *ptr, long size)) throw () |
567 | { |
557 | { |
568 | ev_set_allocator (cb); |
558 | ev_set_allocator (cb); |
569 | } |
559 | } |
570 | |
560 | |
571 | inline void set_syserr_cb (void (*cb)(const char *msg)) EV_THROW () |
561 | inline void set_syserr_cb (void (*cb)(const char *msg)) throw () |
572 | { |
562 | { |
573 | ev_set_syserr_cb (cb); |
563 | ev_set_syserr_cb (cb); |
574 | } |
564 | } |
575 | |
565 | |
576 | #if EV_MULTIPLICITY |
566 | #if EV_MULTIPLICITY |
577 | #define EV_CONSTRUCT(cppstem,cstem) \ |
567 | #define EV_CONSTRUCT(cppstem,cstem) \ |
578 | (EV_PX = get_default_loop ()) EV_THROW () \ |
568 | (EV_PX = get_default_loop ()) throw () \ |
579 | : base<ev_ ## cstem, cppstem> (EV_A) \ |
569 | : base<ev_ ## cstem, cppstem> (EV_A) \ |
580 | { \ |
570 | { \ |
581 | } |
571 | } |
582 | #else |
572 | #else |
583 | #define EV_CONSTRUCT(cppstem,cstem) \ |
573 | #define EV_CONSTRUCT(cppstem,cstem) \ |
584 | () EV_THROW () \ |
574 | () throw () \ |
585 | { \ |
575 | { \ |
586 | } |
576 | } |
587 | #endif |
577 | #endif |
588 | |
578 | |
589 | /* using a template here would require quite a bit more lines, |
579 | /* using a template here would require quite a bit more lines, |
590 | * so a macro solution was chosen */ |
580 | * so a macro solution was chosen */ |
591 | #define EV_BEGIN_WATCHER(cppstem,cstem) \ |
581 | #define EV_BEGIN_WATCHER(cppstem,cstem) \ |
592 | \ |
582 | \ |
593 | struct cppstem : base<ev_ ## cstem, cppstem> \ |
583 | struct cppstem : base<ev_ ## cstem, cppstem> \ |
594 | { \ |
584 | { \ |
595 | void start () EV_THROW () \ |
585 | void start () throw () \ |
596 | { \ |
586 | { \ |
597 | ev_ ## cstem ## _start (EV_A_ static_cast<ev_ ## cstem *>(this)); \ |
587 | ev_ ## cstem ## _start (EV_A_ static_cast<ev_ ## cstem *>(this)); \ |
598 | } \ |
588 | } \ |
599 | \ |
589 | \ |
600 | void stop () EV_THROW () \ |
590 | void stop () throw () \ |
601 | { \ |
591 | { \ |
602 | ev_ ## cstem ## _stop (EV_A_ static_cast<ev_ ## cstem *>(this)); \ |
592 | ev_ ## cstem ## _stop (EV_A_ static_cast<ev_ ## cstem *>(this)); \ |
603 | } \ |
593 | } \ |
604 | \ |
594 | \ |
605 | cppstem EV_CONSTRUCT(cppstem,cstem) \ |
595 | cppstem EV_CONSTRUCT(cppstem,cstem) \ |
606 | \ |
596 | \ |
607 | ~cppstem () EV_THROW () \ |
597 | ~cppstem () throw () \ |
608 | { \ |
598 | { \ |
609 | stop (); \ |
599 | stop (); \ |
610 | } \ |
600 | } \ |
611 | \ |
601 | \ |
612 | using base<ev_ ## cstem, cppstem>::set; \ |
602 | using base<ev_ ## cstem, cppstem>::set; \ |
… | |
… | |
621 | |
611 | |
622 | #define EV_END_WATCHER(cppstem,cstem) \ |
612 | #define EV_END_WATCHER(cppstem,cstem) \ |
623 | }; |
613 | }; |
624 | |
614 | |
625 | EV_BEGIN_WATCHER (io, io) |
615 | EV_BEGIN_WATCHER (io, io) |
626 | void set (int fd, int events) EV_THROW () |
616 | void set (int fd, int events) throw () |
627 | { |
617 | { |
628 | int active = is_active (); |
618 | int active = is_active (); |
629 | if (active) stop (); |
619 | if (active) stop (); |
630 | ev_io_set (static_cast<ev_io *>(this), fd, events); |
620 | ev_io_set (static_cast<ev_io *>(this), fd, events); |
631 | if (active) start (); |
621 | if (active) start (); |
632 | } |
622 | } |
633 | |
623 | |
634 | void set (int events) EV_THROW () |
624 | void set (int events) throw () |
635 | { |
625 | { |
636 | int active = is_active (); |
626 | int active = is_active (); |
637 | if (active) stop (); |
627 | if (active) stop (); |
638 | ev_io_set (static_cast<ev_io *>(this), fd, events); |
628 | ev_io_set (static_cast<ev_io *>(this), fd, events); |
639 | if (active) start (); |
629 | if (active) start (); |
640 | } |
630 | } |
641 | |
631 | |
642 | void start (int fd, int events) EV_THROW () |
632 | void start (int fd, int events) throw () |
643 | { |
633 | { |
644 | set (fd, events); |
634 | set (fd, events); |
645 | start (); |
635 | start (); |
646 | } |
636 | } |
647 | EV_END_WATCHER (io, io) |
637 | EV_END_WATCHER (io, io) |
648 | |
638 | |
649 | EV_BEGIN_WATCHER (timer, timer) |
639 | EV_BEGIN_WATCHER (timer, timer) |
650 | void set (ev_tstamp after, ev_tstamp repeat = 0.) EV_THROW () |
640 | void set (ev_tstamp after, ev_tstamp repeat = 0.) throw () |
651 | { |
641 | { |
652 | int active = is_active (); |
642 | int active = is_active (); |
653 | if (active) stop (); |
643 | if (active) stop (); |
654 | ev_timer_set (static_cast<ev_timer *>(this), after, repeat); |
644 | ev_timer_set (static_cast<ev_timer *>(this), after, repeat); |
655 | if (active) start (); |
645 | if (active) start (); |
656 | } |
646 | } |
657 | |
647 | |
658 | void start (ev_tstamp after, ev_tstamp repeat = 0.) EV_THROW () |
648 | void start (ev_tstamp after, ev_tstamp repeat = 0.) throw () |
659 | { |
649 | { |
660 | set (after, repeat); |
650 | set (after, repeat); |
661 | start (); |
651 | start (); |
662 | } |
652 | } |
663 | |
653 | |
664 | void again () EV_THROW () |
654 | void again () throw () |
665 | { |
655 | { |
666 | ev_timer_again (EV_A_ static_cast<ev_timer *>(this)); |
656 | ev_timer_again (EV_A_ static_cast<ev_timer *>(this)); |
667 | } |
657 | } |
668 | EV_END_WATCHER (timer, timer) |
658 | EV_END_WATCHER (timer, timer) |
669 | |
659 | |
670 | #if EV_PERIODIC_ENABLE |
660 | #if EV_PERIODIC_ENABLE |
671 | EV_BEGIN_WATCHER (periodic, periodic) |
661 | EV_BEGIN_WATCHER (periodic, periodic) |
672 | void set (ev_tstamp at, ev_tstamp interval = 0.) EV_THROW () |
662 | void set (ev_tstamp at, ev_tstamp interval = 0.) throw () |
673 | { |
663 | { |
674 | int active = is_active (); |
664 | int active = is_active (); |
675 | if (active) stop (); |
665 | if (active) stop (); |
676 | ev_periodic_set (static_cast<ev_periodic *>(this), at, interval, 0); |
666 | ev_periodic_set (static_cast<ev_periodic *>(this), at, interval, 0); |
677 | if (active) start (); |
667 | if (active) start (); |
678 | } |
668 | } |
679 | |
669 | |
680 | void start (ev_tstamp at, ev_tstamp interval = 0.) EV_THROW () |
670 | void start (ev_tstamp at, ev_tstamp interval = 0.) throw () |
681 | { |
671 | { |
682 | set (at, interval); |
672 | set (at, interval); |
683 | start (); |
673 | start (); |
684 | } |
674 | } |
685 | |
675 | |
686 | void again () EV_THROW () |
676 | void again () throw () |
687 | { |
677 | { |
688 | ev_periodic_again (EV_A_ static_cast<ev_periodic *>(this)); |
678 | ev_periodic_again (EV_A_ static_cast<ev_periodic *>(this)); |
689 | } |
679 | } |
690 | EV_END_WATCHER (periodic, periodic) |
680 | EV_END_WATCHER (periodic, periodic) |
691 | #endif |
681 | #endif |
692 | |
682 | |
693 | EV_BEGIN_WATCHER (sig, signal) |
683 | EV_BEGIN_WATCHER (sig, signal) |
694 | void set (int signum) EV_THROW () |
684 | void set (int signum) throw () |
695 | { |
685 | { |
696 | int active = is_active (); |
686 | int active = is_active (); |
697 | if (active) stop (); |
687 | if (active) stop (); |
698 | ev_signal_set (static_cast<ev_signal *>(this), signum); |
688 | ev_signal_set (static_cast<ev_signal *>(this), signum); |
699 | if (active) start (); |
689 | if (active) start (); |
700 | } |
690 | } |
701 | |
691 | |
702 | void start (int signum) EV_THROW () |
692 | void start (int signum) throw () |
703 | { |
693 | { |
704 | set (signum); |
694 | set (signum); |
705 | start (); |
695 | start (); |
706 | } |
696 | } |
707 | EV_END_WATCHER (sig, signal) |
697 | EV_END_WATCHER (sig, signal) |
708 | |
698 | |
709 | EV_BEGIN_WATCHER (child, child) |
699 | EV_BEGIN_WATCHER (child, child) |
710 | void set (int pid) EV_THROW () |
700 | void set (int pid) throw () |
711 | { |
701 | { |
712 | int active = is_active (); |
702 | int active = is_active (); |
713 | if (active) stop (); |
703 | if (active) stop (); |
714 | ev_child_set (static_cast<ev_child *>(this), pid); |
704 | ev_child_set (static_cast<ev_child *>(this), pid); |
715 | if (active) start (); |
705 | if (active) start (); |
716 | } |
706 | } |
717 | |
707 | |
718 | void start (int pid) EV_THROW () |
708 | void start (int pid) throw () |
719 | { |
709 | { |
720 | set (pid); |
710 | set (pid); |
721 | start (); |
711 | start (); |
722 | } |
712 | } |
723 | EV_END_WATCHER (child, child) |
713 | EV_END_WATCHER (child, child) |
724 | |
714 | |
725 | #if EV_STAT_ENABLE |
715 | #if EV_STAT_ENABLE |
726 | EV_BEGIN_WATCHER (stat, stat) |
716 | EV_BEGIN_WATCHER (stat, stat) |
727 | void set (const char *path, ev_tstamp interval = 0.) EV_THROW () |
717 | void set (const char *path, ev_tstamp interval = 0.) throw () |
728 | { |
718 | { |
729 | int active = is_active (); |
719 | int active = is_active (); |
730 | if (active) stop (); |
720 | if (active) stop (); |
731 | ev_stat_set (static_cast<ev_stat *>(this), path, interval); |
721 | ev_stat_set (static_cast<ev_stat *>(this), path, interval); |
732 | if (active) start (); |
722 | if (active) start (); |
733 | } |
723 | } |
734 | |
724 | |
735 | void start (const char *path, ev_tstamp interval = 0.) EV_THROW () |
725 | void start (const char *path, ev_tstamp interval = 0.) throw () |
736 | { |
726 | { |
737 | stop (); |
727 | stop (); |
738 | set (path, interval); |
728 | set (path, interval); |
739 | start (); |
729 | start (); |
740 | } |
730 | } |
741 | |
731 | |
742 | void update () EV_THROW () |
732 | void update () throw () |
743 | { |
733 | { |
744 | ev_stat_stat (EV_A_ static_cast<ev_stat *>(this)); |
734 | ev_stat_stat (EV_A_ static_cast<ev_stat *>(this)); |
745 | } |
735 | } |
746 | EV_END_WATCHER (stat, stat) |
736 | EV_END_WATCHER (stat, stat) |
747 | #endif |
737 | #endif |
748 | |
738 | |
749 | EV_BEGIN_WATCHER (idle, idle) |
739 | EV_BEGIN_WATCHER (idle, idle) |
750 | void set () EV_THROW () { } |
740 | void set () throw () { } |
751 | EV_END_WATCHER (idle, idle) |
741 | EV_END_WATCHER (idle, idle) |
752 | |
742 | |
753 | EV_BEGIN_WATCHER (prepare, prepare) |
743 | EV_BEGIN_WATCHER (prepare, prepare) |
754 | void set () EV_THROW () { } |
744 | void set () throw () { } |
755 | EV_END_WATCHER (prepare, prepare) |
745 | EV_END_WATCHER (prepare, prepare) |
756 | |
746 | |
757 | EV_BEGIN_WATCHER (check, check) |
747 | EV_BEGIN_WATCHER (check, check) |
758 | void set () EV_THROW () { } |
748 | void set () throw () { } |
759 | EV_END_WATCHER (check, check) |
749 | EV_END_WATCHER (check, check) |
760 | |
750 | |
761 | #if EV_EMBED_ENABLE |
751 | #if EV_EMBED_ENABLE |
762 | EV_BEGIN_WATCHER (embed, embed) |
752 | EV_BEGIN_WATCHER (embed, embed) |
763 | void start (struct ev_loop *embedded_loop) EV_THROW () |
753 | void start (struct ev_loop *embedded_loop) throw () |
764 | { |
754 | { |
765 | stop (); |
755 | stop (); |
766 | ev_embed_set (static_cast<ev_embed *>(this), embedded_loop); |
756 | ev_embed_set (static_cast<ev_embed *>(this), embedded_loop); |
767 | start (); |
757 | start (); |
768 | } |
758 | } |
… | |
… | |
774 | EV_END_WATCHER (embed, embed) |
764 | EV_END_WATCHER (embed, embed) |
775 | #endif |
765 | #endif |
776 | |
766 | |
777 | #if EV_FORK_ENABLE |
767 | #if EV_FORK_ENABLE |
778 | EV_BEGIN_WATCHER (fork, fork) |
768 | EV_BEGIN_WATCHER (fork, fork) |
779 | void set () EV_THROW () { } |
769 | void set () throw () { } |
780 | EV_END_WATCHER (fork, fork) |
770 | EV_END_WATCHER (fork, fork) |
781 | #endif |
771 | #endif |
782 | |
772 | |
783 | #undef EV_PX |
773 | #undef EV_PX |
784 | #undef EV_PX_ |
774 | #undef EV_PX_ |
… | |
… | |
786 | #undef EV_BEGIN_WATCHER |
776 | #undef EV_BEGIN_WATCHER |
787 | #undef EV_END_WATCHER |
777 | #undef EV_END_WATCHER |
788 | |
778 | |
789 | } |
779 | } |
790 | |
780 | |
791 | #undef EV_THROW |
|
|
792 | |
|
|
793 | #endif |
781 | #endif |
794 | |
782 | |