From 260e2814495fb893fab3f089748c443c3f03fb23 Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Tue, 29 May 2012 01:43:39 +0200 Subject: [PATCH] #2102 - porting over the fix for Netty/356 --- .../java/akka/util/internal/HashedWheelTimer.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/akka-actor/src/main/java/akka/util/internal/HashedWheelTimer.java b/akka-actor/src/main/java/akka/util/internal/HashedWheelTimer.java index 25841861c5..7a497b8442 100644 --- a/akka-actor/src/main/java/akka/util/internal/HashedWheelTimer.java +++ b/akka-actor/src/main/java/akka/util/internal/HashedWheelTimer.java @@ -89,6 +89,7 @@ public class HashedWheelTimer implements Timer { final ReusableIterator[] iterators; final int mask; final ReadWriteLock lock = new ReentrantReadWriteLock(); + final boolean isWindows = System.getProperty("os.name", "").toLowerCase().indexOf("win") >= 0; volatile int wheelCursor; private LoggingAdapter logger; @@ -389,7 +390,17 @@ public class HashedWheelTimer implements Timer { for (;;) { final long currentTime = System.nanoTime(); - final long sleepTime = (tickDuration * tick - (currentTime - startTime)); + + long sleepTime = tickDuration * tick - (currentTime - startTime); + + // Check if we run on windows, as if thats the case we will need + // to round the sleepTime as workaround for a bug that only affect + // the JVM if it runs on windows. + // + // See https://github.com/netty/netty/issues/356 + if (isWindows) { + sleepTime = (sleepTime / 10) * 10; + } if (sleepTime <= 0) { break;