summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorroot <root>2007-12-03 13:41:24 +0000
committerroot <root>2007-12-03 13:41:24 +0000
commiteb7909955a094de6e667e3e9f88ddbad46fc93b6 (patch)
treebac295fb43e74b3390fa853d4d4169bc9b520aec
parentf6cc1f750a321b2c6e30637963d3e624c7a8e5ae (diff)
*** empty log message ***
-rw-r--r--ev.c7
-rw-r--r--ev.h1
-rw-r--r--ev.pod10
-rw-r--r--ev_vars.h1
-rw-r--r--ev_wrap.h1
5 files changed, 20 insertions, 0 deletions
diff --git a/ev.c b/ev.c
index 9f7e2be..8cb6141 100644
--- a/ev.c
+++ b/ev.c
@@ -888,6 +888,12 @@ ev_backend (EV_P)
return backend;
}
+unsigned int
+ev_loop_count (EV_P)
+{
+ return loop_count;
+}
+
static void noinline
loop_init (EV_P_ unsigned int flags)
{
@@ -1420,6 +1426,7 @@ ev_loop (EV_P_ int flags)
if (expect_false (block < 0.)) block = 0.;
}
+ ++loop_count;
backend_poll (EV_A_ block);
}
diff --git a/ev.h b/ev.h
index ad9bb8e..946963d 100644
--- a/ev.h
+++ b/ev.h
@@ -388,6 +388,7 @@ void ev_default_destroy (void); /* destroy the default loop */
void ev_default_fork (void);
unsigned int ev_backend (EV_P);
+unsigned int ev_loop_count (EV_P);
#endif
#define EVLOOP_NONBLOCK 1 /* do not block/wait */
diff --git a/ev.pod b/ev.pod
index ed0ac1b..f372d94 100644
--- a/ev.pod
+++ b/ev.pod
@@ -432,6 +432,16 @@ Like C<ev_default_fork>, but acts on an event loop created by
C<ev_loop_new>. Yes, you have to call this on every allocated event loop
after fork, and how you do this is entirely your own problem.
+=item unsigned int ev_loop_count (loop)
+
+Returns the count of loop iterations for the loop, which is identical to
+the number of times libev did poll for new events. It starts at C<0> and
+happily wraps around with enough iterations.
+
+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_backend (loop)
Returns one of the C<EVBACKEND_*> flags indicating the event backend in
diff --git a/ev_vars.h b/ev_vars.h
index 6b0c3e9..fa6ae9b 100644
--- a/ev_vars.h
+++ b/ev_vars.h
@@ -5,6 +5,7 @@ VARx(ev_tstamp, mn_now) /* monotonic clock "now" */
VARx(ev_tstamp, rtmn_diff) /* difference realtime - monotonic time */
VARx(int, backend)
VARx(int, activecnt) /* total number of active events ("refcount") */
+VARx(unsigned int, loop_count); /* total number of loop iterations/blocks */
VARx(ev_tstamp, backend_fudge) /* assumed typical timer resolution */
VAR (backend_modify, void (*backend_modify)(EV_P_ int fd, int oev, int nev))
diff --git a/ev_wrap.h b/ev_wrap.h
index c0d9ce0..957d5fa 100644
--- a/ev_wrap.h
+++ b/ev_wrap.h
@@ -4,6 +4,7 @@
#define rtmn_diff ((loop)->rtmn_diff)
#define backend ((loop)->backend)
#define activecnt ((loop)->activecnt)
+#define loop_count ((loop)->loop_count);
#define backend_fudge ((loop)->backend_fudge)
#define backend_modify ((loop)->backend_modify)
#define backend_poll ((loop)->backend_poll)