From eb1c97b3b99bca59971809260ad2977d5e5c886b Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Wed, 26 Aug 2015 11:21:57 +0200 Subject: [PATCH] [#4110] Correct javadocs of MpscLinkedQueue Motivation: The javadocs are incorrect and so give false impressions of use-pattern. Modifications: - Fix javadocs of which operations are allowed from multiple threads concurrently. - Let isEmpty() work concurrently. Result: Correctly document usage-patterns. --- .../netty/util/internal/MpscLinkedQueue.java | 25 ++++++++----------- .../util/internal/MpscLinkedQueueHeadRef.java | 2 +- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/common/src/main/java/io/netty/util/internal/MpscLinkedQueue.java b/common/src/main/java/io/netty/util/internal/MpscLinkedQueue.java index c1b931a562..a1a8c2c9d1 100644 --- a/common/src/main/java/io/netty/util/internal/MpscLinkedQueue.java +++ b/common/src/main/java/io/netty/util/internal/MpscLinkedQueue.java @@ -32,22 +32,19 @@ import java.util.Queue; * A lock-free concurrent single-consumer multi-producer {@link Queue}. * It allows multiple producer threads to perform the following operations simultaneously: * * .. while only one consumer thread is allowed to perform the following operations exclusively: * * * The behavior of this implementation is undefined if you perform the operations for a consumer thread only @@ -184,7 +181,7 @@ final class MpscLinkedQueue extends MpscLinkedQueueTailRef implements Queu @Override public boolean isEmpty() { - return peekNode() == null; + return headRef() == tailRef(); } @Override diff --git a/common/src/main/java/io/netty/util/internal/MpscLinkedQueueHeadRef.java b/common/src/main/java/io/netty/util/internal/MpscLinkedQueueHeadRef.java index cf8d4a91b2..fabcf42ed4 100644 --- a/common/src/main/java/io/netty/util/internal/MpscLinkedQueueHeadRef.java +++ b/common/src/main/java/io/netty/util/internal/MpscLinkedQueueHeadRef.java @@ -38,7 +38,7 @@ abstract class MpscLinkedQueueHeadRef extends MpscLinkedQueuePad0 implemen UPDATER = updater; } - private transient volatile MpscLinkedQueueNode headRef; + private transient volatile MpscLinkedQueueNode headRef; protected final MpscLinkedQueueNode headRef() { return headRef;