#2102 - porting over the fix for Netty/356

This commit is contained in:
Viktor Klang 2012-05-29 01:43:39 +02:00
parent c357ba426e
commit 260e281449

View file

@ -89,6 +89,7 @@ public class HashedWheelTimer implements Timer {
final ReusableIterator<HashedWheelTimeout>[] 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;