From 40b1f26c34b3520778f95ca28e024d75bed0ecae Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Sun, 28 Sep 2008 14:12:28 +0000 Subject: [PATCH] Made sure all segments are evaluated on poll for potentially better throughput (still proof-of-concept - getting better) --- .../java/org/jboss/netty/util/ConcurrentFastQueue.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/jboss/netty/util/ConcurrentFastQueue.java b/src/main/java/org/jboss/netty/util/ConcurrentFastQueue.java index 4a4c0e46f9..0d53d14a4b 100644 --- a/src/main/java/org/jboss/netty/util/ConcurrentFastQueue.java +++ b/src/main/java/org/jboss/netty/util/ConcurrentFastQueue.java @@ -66,6 +66,7 @@ public class ConcurrentFastQueue { } public E poll() { + int oldPollIndex = pollIndex; while (pollIndex < segments.length) { E v = segments[pollIndex].poll(); if (v != null) { @@ -74,7 +75,14 @@ public class ConcurrentFastQueue { pollIndex ++; } - pollIndex = 0; + + for (pollIndex = 0; pollIndex < oldPollIndex; pollIndex ++) { + E v = segments[pollIndex].poll(); + if (v != null) { + return v; + } + } + return null; }