Package org.eclipse.jetty.util
Class ConcurrentArrayQueue<T>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractQueue<T>
org.eclipse.jetty.util.ConcurrentArrayQueue<T>
- Type Parameters:
T- the Array entry type
- All Implemented Interfaces:
java.lang.Iterable<T>,java.util.Collection<T>,java.util.Queue<T>
public class ConcurrentArrayQueue<T>
extends java.util.AbstractQueue<T>
A concurrent, unbounded implementation of
Queue that uses singly-linked array blocks
to store elements.
This class is a drop-in replacement for ConcurrentLinkedQueue, with similar performance
but producing less garbage because arrays are used to store elements rather than nodes.
The algorithm used is a variation of the algorithm from Gidenstam, Sundell and Tsigas (http://www.adm.hb.se/~AGD/Presentations/CacheAwareQueue_OPODIS.pdf).
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classConcurrentArrayQueue.Block<E> -
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_BLOCK_SIZEstatic java.lang.ObjectREMOVED_ELEMENT -
Constructor Summary
Constructors Constructor Description ConcurrentArrayQueue()ConcurrentArrayQueue(int blockSize) -
Method Summary
Modifier and Type Method Description protected booleancasHeadBlock(ConcurrentArrayQueue.Block<T> current, ConcurrentArrayQueue.Block<T> update)protected booleancasTailBlock(ConcurrentArrayQueue.Block<T> current, ConcurrentArrayQueue.Block<T> update)protected intgetBlockCount()intgetBlockSize()intgetExactSize()protected ConcurrentArrayQueue.Block<T>getHeadBlock()protected ConcurrentArrayQueue.Block<T>getTailBlock()booleanisEmpty()java.util.Iterator<T>iterator()protected ConcurrentArrayQueue.Block<T>newBlock()booleanoffer(T item)intoriginalSize()this method has been modified from original jetty version, it only returns a size rounded to 'blockSize'Tpeek()Tpoll()booleanremove(java.lang.Object o)booleanremoveAll(java.util.Collection<?> c)booleanretainAll(java.util.Collection<?> c)intsize()Methods inherited from class java.util.AbstractCollection
contains, containsAll, toArray, toArray, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Field Details
-
DEFAULT_BLOCK_SIZE
public static final int DEFAULT_BLOCK_SIZE- See Also:
- Constant Field Values
-
REMOVED_ELEMENT
public static final java.lang.Object REMOVED_ELEMENT
-
-
Constructor Details
-
ConcurrentArrayQueue
public ConcurrentArrayQueue() -
ConcurrentArrayQueue
public ConcurrentArrayQueue(int blockSize)
-
-
Method Details
-
getBlockSize
public int getBlockSize() -
getHeadBlock
-
getTailBlock
-
offer
-
casTailBlock
protected boolean casTailBlock(ConcurrentArrayQueue.Block<T> current, ConcurrentArrayQueue.Block<T> update) -
isEmpty
public boolean isEmpty() -
poll
-
casHeadBlock
protected boolean casHeadBlock(ConcurrentArrayQueue.Block<T> current, ConcurrentArrayQueue.Block<T> update) -
peek
-
remove
public boolean remove(java.lang.Object o) -
removeAll
public boolean removeAll(java.util.Collection<?> c) -
retainAll
public boolean retainAll(java.util.Collection<?> c) -
iterator
-
size
public int size() -
originalSize
public int originalSize()this method has been modified from original jetty version, it only returns a size rounded to 'blockSize'- Returns:
-
getExactSize
public int getExactSize() -
newBlock
-
getBlockCount
protected int getBlockCount()
-