Made sure all segments are evaluated on poll for potentially better throughput (still proof-of-concept - getting better)

This commit is contained in:
Trustin Lee 2008-09-28 14:12:28 +00:00
parent 597cbd870c
commit 40b1f26c34

View File

@ -66,6 +66,7 @@ public class ConcurrentFastQueue<E> {
} }
public E poll() { public E poll() {
int oldPollIndex = pollIndex;
while (pollIndex < segments.length) { while (pollIndex < segments.length) {
E v = segments[pollIndex].poll(); E v = segments[pollIndex].poll();
if (v != null) { if (v != null) {
@ -74,7 +75,14 @@ public class ConcurrentFastQueue<E> {
pollIndex ++; pollIndex ++;
} }
pollIndex = 0;
for (pollIndex = 0; pollIndex < oldPollIndex; pollIndex ++) {
E v = segments[pollIndex].poll();
if (v != null) {
return v;
}
}
return null; return null;
} }