Hi,
This patch works around the problem with some ev_timer timeout values
causing extreme cpu load on win32, that at the moment is observed at
least on WinXP virtual machine under Parallels (ev_time is ticking at
64Hz in that case, compared to 2000Hz on Windows 7 physical machine).
diff --git a/ev_select.c b/ev_select.c
index 0ea9467..a706dfe 100644
--- a/ev_select.c
+++ b/ev_select.c
@@ -269,7 +269,11 @@ select_poll (EV_P_ ev_tstamp timeout)
int inline_size
select_init (EV_P_ int flags)
{
+#ifdef _WIN32
+ backend_fudge = ev_win32_fudge ();
+#else
backend_fudge = 0.; /* posix says this is zero */
+#endif
backend_modify = select_modify;
backend_poll = select_poll;
diff --git a/ev_win32.c b/ev_win32.c
index 338886e..d3bc33e 100644
--- a/ev_win32.c
+++ b/ev_win32.c
@@ -149,5 +149,27 @@ ev_time (void)
return (LONGLONG)(ui.QuadPart - 116444736000000000) * 1e-7;
}
+static ev_tstamp
+ev_win32_fudge (void)
+{
+ int k = 0;
+ ev_tstamp d, d0, t, t0;
+
+ t0 = ev_time ();
+ while (k < 4)
+ {
+ t = ev_time ();
+ d0 = t - t0;
+ if (d0 > 0.)
+ {
+ if (k == 0 || d > d0)
+ d = d0;
+ t0 = t;
+ ++k;
+ }
+ }
+ return d;
+}
+
#endif
_______________________________________________
libev mailing list
[email protected]
http://lists.schmorp.de/cgi-bin/mailman/listinfo/libev