From d099a86e50547e1d765bc0e150f2ff43fb4b486a Mon Sep 17 00:00:00 2001 From: kappa1 Date: Thu, 1 Mar 2012 22:34:34 +0000 Subject: [PATCH] Tweak Display.sync() method a little to reduce the Thread.yield() time even further, now with a minimum of 0 yield time. --- src/java/org/lwjgl/opengl/Display.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/java/org/lwjgl/opengl/Display.java b/src/java/org/lwjgl/opengl/Display.java index 6e5bfdb8..aab4a4b1 100644 --- a/src/java/org/lwjgl/opengl/Display.java +++ b/src/java/org/lwjgl/opengl/Display.java @@ -86,7 +86,7 @@ public final class Display { private static boolean syncInitiated; /** adaptive time to yield instead of sleeping in sync()*/ - private static long adaptiveYieldTime = 1000*1000; + private static long adaptiveYieldTime; /** X coordinate of the window */ private static int x = -1; @@ -444,12 +444,12 @@ public final class Display { // auto tune the amount of time to yield if (overSleep > adaptiveYieldTime) { - // increase by 500 microseconds (half a ms) - adaptiveYieldTime = Math.min(adaptiveYieldTime + 500*1000, sleepTime); + // increase by 200 microseconds (1/5 a ms) + adaptiveYieldTime = Math.min(adaptiveYieldTime + 200*1000, sleepTime); } - else if (overSleep < adaptiveYieldTime - 1000*1000) { + else if (overSleep < adaptiveYieldTime - 200*1000) { // decrease by 5 microseconds - adaptiveYieldTime = Math.max(adaptiveYieldTime - 5*1000, 1000*1000); + adaptiveYieldTime = Math.max(adaptiveYieldTime - 2*1000, 0); } }