From 9c921b050fb56b1285506bc8a33e6753806b15e4 Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Wed, 17 Oct 2012 15:26:54 +0200 Subject: [PATCH] Some more optimization in HashedWheelTimer based on the comments of @viktorklang --- src/main/java/org/jboss/netty/util/HashedWheelTimer.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/jboss/netty/util/HashedWheelTimer.java b/src/main/java/org/jboss/netty/util/HashedWheelTimer.java index 055feab1ca..01afab1692 100644 --- a/src/main/java/org/jboss/netty/util/HashedWheelTimer.java +++ b/src/main/java/org/jboss/netty/util/HashedWheelTimer.java @@ -280,9 +280,8 @@ public class HashedWheelTimer implements Timer { TimerTask.class.getSimpleName()); } - if (!workerState.compareAndSet(1, 2)) { - // workerState can be 0 or 2 at this moment - let it always be 2. - workerState.set(2); + if (workerState.getAndSet(2) != 1) { + // workerState can be 0 or 2 at this moment, so just return an empty set return Collections.emptySet(); }