[#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.
This commit is contained in:
Norman Maurer 2015-08-26 11:21:57 +02:00
parent 94249a8d87
commit 15de021a86
2 changed files with 12 additions and 15 deletions

View File

@ -32,22 +32,19 @@ import java.util.Queue;
* A lock-free concurrent single-consumer multi-producer {@link Queue}. * A lock-free concurrent single-consumer multi-producer {@link Queue}.
* It allows multiple producer threads to perform the following operations simultaneously: * It allows multiple producer threads to perform the following operations simultaneously:
* <ul> * <ul>
* <li>{@link #offer(Object)}, {@link #add(Object)}, and {@link #addAll(Collection)}</li> * <li>{@link #offer(Object)}, {@link #add(Object)}, {@link #addAll(Collection)}</li>
* <li>All other read-only operations: * <li>{@link #isEmpty()}</li>
* <ul>
* <li>{@link #contains(Object)} and {@link #containsAll(Collection)}</li>
* <li>{@link #element()}, {@link #peek()}</li>
* <li>{@link #size()} and {@link #isEmpty()}</li>
* <li>{@link #iterator()} (except {@link Iterator#remove()}</li>
* <li>{@link #toArray()} and {@link #toArray(Object[])}</li>
* </ul>
* </li>
* </ul> * </ul>
* .. while only one consumer thread is allowed to perform the following operations exclusively: * .. while only one consumer thread is allowed to perform the following operations exclusively:
* <ul> * <ul>
* <li>{@link #poll()} and {@link #remove()}</li> * <li>{@link #poll()} and {@link #remove()}</li>
* <li>{@link #element()}, {@link #peek()}</li>
* <li>{@link #remove(Object)}, {@link #removeAll(Collection)}, and {@link #retainAll(Collection)}</li> * <li>{@link #remove(Object)}, {@link #removeAll(Collection)}, and {@link #retainAll(Collection)}</li>
* <li>{@link #clear()}</li> {@link #} * <li>{@link #clear()}</li> {@link #}
* <li>{@link #iterator()}</li>
* <li>{@link #toArray()} and {@link #toArray(Object[])}</li>
* <li>{@link #contains(Object)} and {@link #containsAll(Collection)}</li>
* <li>{@link #size()}</li>
* </ul> * </ul>
* *
* <strong>The behavior of this implementation is undefined if you perform the operations for a consumer thread only * <strong>The behavior of this implementation is undefined if you perform the operations for a consumer thread only
@ -184,7 +181,7 @@ final class MpscLinkedQueue<E> extends MpscLinkedQueueTailRef<E> implements Queu
@Override @Override
public boolean isEmpty() { public boolean isEmpty() {
return peekNode() == null; return headRef() == tailRef();
} }
@Override @Override