diff options
| -rw-r--r-- | Changes | 5 | ||||
| -rw-r--r-- | Symbols.ev | 1 | ||||
| -rw-r--r-- | ev.c | 12 | ||||
| -rw-r--r-- | ev.h | 8 | ||||
| -rw-r--r-- | ev.pod | 12 | ||||
| -rw-r--r-- | ev_vars.h | 4 | ||||
| -rw-r--r-- | ev_wrap.h | 4 | 
7 files changed, 39 insertions, 7 deletions
| @@ -3,7 +3,8 @@ Revision history for libev, a high-performance and full-featured event loop.  TODO: ev_walk  TODO: child wactehr execution order w.r.t. childsigcb reg. priorities  TODO: remain -TODO: io_collect documentation +	- ev_unloop and ev_loop wrongly used a global variable to exit loops, +          instead of using a per-loop variable (bug caught by accident...).  	- Denis F. Latypoff corrected many typos in example code snippets.  	- the ev_set_io_collect_interval interpretation has changed.          - honor autoconf detection of EV_USE_CLOCK_SYSCALL, also double- @@ -11,6 +12,8 @@ TODO: io_collect documentation            use it (reported by ry@tinyclouds).          - use GetSystemTimeAsFileTime instead of _timeb on windows, for            slightly higher accuracy. +        - properly declare ev_loop_verify even when !EV_MULTIPLICITY. +        - implement ev_loop_depth.  3.6  Tue Apr 28 02:49:30 CEST 2009  	- multiple timers becoming ready within an event loop iteration @@ -27,6 +27,7 @@ ev_io_start  ev_io_stop  ev_loop  ev_loop_count +ev_loop_depth  ev_loop_destroy  ev_loop_fork  ev_loop_new @@ -1360,6 +1360,12 @@ ev_loop_count (EV_P)    return loop_count;  } +unsigned int +ev_loop_depth (EV_P) +{ +  return loop_depth; +} +  void  ev_set_io_collect_interval (EV_P_ ev_tstamp interval)  { @@ -2022,11 +2028,11 @@ time_update (EV_P_ ev_tstamp max_block)      }  } -static int loop_done; -  void  ev_loop (EV_P_ int flags)  { +  ++loop_depth; +    loop_done = EVUNLOOP_CANCEL;    call_pending (EV_A); /* in case we recurse, ensure ordering stays nice and clean */ @@ -2151,6 +2157,8 @@ ev_loop (EV_P_ int flags)    if (loop_done == EVUNLOOP_ONE)      loop_done = EVUNLOOP_CANCEL; + +  --loop_depth;  }  void @@ -461,7 +461,6 @@ ev_default_loop (unsigned int flags)  struct ev_loop *ev_loop_new (unsigned int flags);  void ev_loop_destroy (EV_P);  void ev_loop_fork (EV_P); -void ev_loop_verify (EV_P);  ev_tstamp ev_now (EV_P); /* time w.r.t. timers and the eventloop, updated after each poll */  void ev_now_update (EV_P); @@ -498,6 +497,11 @@ void ev_default_destroy (void); /* destroy the default loop */  /* you can actually call it at any time, anywhere :) */  void ev_default_fork (void); +unsigned int ev_backend (EV_P);     /* backend in use by loop */ +unsigned int ev_loop_count (EV_P);  /* number of loop iterations */ +unsigned int ev_loop_depth (EV_P);  /* #ev_loop enters - #ev_loop leaves */ +void         ev_loop_verify (EV_P); /* abort if loop data corrupted */ +  #if EV_WALK_ENABLE  /* walk (almost) all watchers in the loop of a given type, invoking the */  /* callback on every such watcher. The callback might stop the watcher, */ @@ -505,8 +509,6 @@ void ev_default_fork (void);  void ev_walk (EV_P_ int types, void (*cb)(EV_P_ int type, void *w));  #endif -unsigned int ev_backend (EV_P);    /* backend in use by loop */ -unsigned int ev_loop_count (EV_P); /* number of loop iterations */  #endif /* prototypes */  #define EVLOOP_NONBLOCK	1 /* do not block/wait */ @@ -623,6 +623,18 @@ This value can sometimes be useful as a generation counter of sorts (it  "ticks" the number of loop iterations), as it roughly corresponds with  C<ev_prepare> and C<ev_check> calls. +=item unsigned int ev_loop_depth (loop) + +Returns the number of times C<ev_loop> was entered minus the number of +times C<ev_loop> was exited, in other words, the recursion depth. + +Outside C<ev_loop>, this number is zero. In a callback, this number is +C<1>, unless C<ev_loop> was invoked recursively (or from another thread), +in which case it is higher. + +Leaving C<ev_loop> abnormally (setjmp/longjmp, cancelling the thread +etc.), doesn't count as exit. +  =item unsigned int ev_backend (loop)  Returns one of the C<EVBACKEND_*> flags indicating the event backend in @@ -1,7 +1,7 @@  /*   * loop member variable declarations   * - * Copyright (c) 2007,2008 Marc Alexander Lehmann <libev@schmorp.de> + * Copyright (c) 2007,2008,2009 Marc Alexander Lehmann <libev@schmorp.de>   * All rights reserved.   *   * Redistribution and use in source and binary forms, with or without modifica- @@ -49,6 +49,8 @@ VARx(ev_tstamp, timeout_blocktime)  VARx(int, backend)  VARx(int, activecnt) /* total number of active events ("refcount") */  VARx(unsigned int, loop_count) /* total number of loop iterations/blocks */ +VARx(unsigned int, loop_depth) /* #ev_loop enters - #ev_loop leaves */ +VARx(char, loop_done)  /* signal by ev_unloop */  VARx(int, backend_fd)  VARx(ev_tstamp, backend_fudge) /* assumed typical timer resolution */ @@ -9,6 +9,8 @@  #define backend ((loop)->backend)  #define activecnt ((loop)->activecnt)  #define loop_count ((loop)->loop_count) +#define loop_depth ((loop)->loop_depth) +#define loop_done ((loop)->loop_done)  #define backend_fd ((loop)->backend_fd)  #define backend_fudge ((loop)->backend_fudge)  #define backend_modify ((loop)->backend_modify) @@ -87,6 +89,8 @@  #undef backend  #undef activecnt  #undef loop_count +#undef loop_depth +#undef loop_done  #undef backend_fd  #undef backend_fudge  #undef backend_modify | 
