public final class MpscLinkedQueue<E> extends Object implements Queue<E>
Queue
.
It allows multiple producer threads to perform the following operations simultaneously:
offer(Object)
, add(Object)
, and addAll(Collection)
The behavior of this implementation is undefined if you perform the operations for a consumer thread only from multiple threads.
The initial implementation is based on:
Modifier and Type | Method and Description |
---|---|
boolean |
add(E e) |
boolean |
addAll(Collection<? extends E> c) |
void |
clear() |
boolean |
contains(Object o) |
boolean |
containsAll(Collection<?> c) |
static <T> Queue<T> |
create()
Create a new
Queue which is safe to use for multiple producers (different threads) and a single
consumer (one thread!). |
E |
element() |
protected MpscLinkedQueueNode<E> |
getAndSetTailRef(MpscLinkedQueueNode<E> tailRef) |
protected MpscLinkedQueueNode<E> |
headRef() |
boolean |
isEmpty() |
Iterator<E> |
iterator() |
protected void |
lazySetHeadRef(MpscLinkedQueueNode<E> headRef) |
boolean |
offer(E value) |
E |
peek() |
E |
poll() |
E |
remove() |
boolean |
remove(Object o) |
boolean |
removeAll(Collection<?> c) |
boolean |
retainAll(Collection<?> c) |
protected void |
setHeadRef(MpscLinkedQueueNode<E> headRef) |
protected void |
setTailRef(MpscLinkedQueueNode<E> tailRef) |
int |
size() |
protected MpscLinkedQueueNode<E> |
tailRef() |
Object[] |
toArray() |
<T> T[] |
toArray(T[] a) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
equals, hashCode, parallelStream, removeIf, spliterator, stream
public static <T> Queue<T> create()
Queue
which is safe to use for multiple producers (different threads) and a single
consumer (one thread!).public int size()
size
in interface Collection<E>
public boolean isEmpty()
isEmpty
in interface Collection<E>
public boolean contains(Object o)
contains
in interface Collection<E>
public boolean add(E e)
public Object[] toArray()
toArray
in interface Collection<E>
public <T> T[] toArray(T[] a)
toArray
in interface Collection<E>
public boolean remove(Object o)
remove
in interface Collection<E>
public boolean containsAll(Collection<?> c)
containsAll
in interface Collection<E>
public boolean addAll(Collection<? extends E> c)
addAll
in interface Collection<E>
public boolean removeAll(Collection<?> c)
removeAll
in interface Collection<E>
public boolean retainAll(Collection<?> c)
retainAll
in interface Collection<E>
public void clear()
clear
in interface Collection<E>
protected final MpscLinkedQueueNode<E> tailRef()
protected final void setTailRef(MpscLinkedQueueNode<E> tailRef)
protected final MpscLinkedQueueNode<E> getAndSetTailRef(MpscLinkedQueueNode<E> tailRef)
protected final MpscLinkedQueueNode<E> headRef()
protected final void setHeadRef(MpscLinkedQueueNode<E> headRef)
protected final void lazySetHeadRef(MpscLinkedQueueNode<E> headRef)
Copyright © 2016. All rights reserved.