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:
Iterable<T>,Collection<T>,Queue<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 -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleancasHeadBlock(ConcurrentArrayQueue.Block<T> current, ConcurrentArrayQueue.Block<T> update) protected booleancasTailBlock(ConcurrentArrayQueue.Block<T> current, ConcurrentArrayQueue.Block<T> update) protected intintintprotected ConcurrentArrayQueue.Block<T>protected ConcurrentArrayQueue.Block<T>booleanisEmpty()iterator()protected ConcurrentArrayQueue.Block<T>newBlock()booleanintthis method has been modified from original jetty version, it only returns a size rounded to 'blockSize'peek()poll()booleanbooleanremoveAll(Collection<?> c) booleanretainAll(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, waitMethods inherited from interface java.util.Collection
contains, containsAll, equals, hashCode, parallelStream, removeIf, spliterator, stream, toArray, toArray, toArray
-
Field Details
-
DEFAULT_BLOCK_SIZE
public static final int DEFAULT_BLOCK_SIZE- See Also:
-
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()- Specified by:
isEmptyin interfaceCollection<T>- Overrides:
isEmptyin classAbstractCollection<T>
-
poll
-
casHeadBlock
protected boolean casHeadBlock(ConcurrentArrayQueue.Block<T> current, ConcurrentArrayQueue.Block<T> update) -
peek
-
remove
- Specified by:
removein interfaceCollection<T>- Overrides:
removein classAbstractCollection<T>
-
removeAll
- Specified by:
removeAllin interfaceCollection<T>- Overrides:
removeAllin classAbstractCollection<T>
-
retainAll
- Specified by:
retainAllin interfaceCollection<T>- Overrides:
retainAllin classAbstractCollection<T>
-
iterator
- Specified by:
iteratorin interfaceCollection<T>- Specified by:
iteratorin interfaceIterable<T>- Specified by:
iteratorin classAbstractCollection<T>
-
size
public int size()- Specified by:
sizein interfaceCollection<T>- Specified by:
sizein classAbstractCollection<T>
-
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()
-