Class BlockingArrayQueue<E>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
org.eclipse.jetty.util.BlockingArrayQueue<E>
- Type Parameters:
 E- The element type
- All Implemented Interfaces:
 Iterable<E>, Collection<E>, BlockingQueue<E>, List<E>, Queue<E>, SequencedCollection<E>
A BlockingQueue backed by a circular array capable of growing.
This queue is uses a variant of the two lock queue algorithm to provide an efficient queue or list backed by a growable circular array.
Unlike ArrayBlockingQueue, this class is able to grow and provides a blocking put(Object) call.
The queue has both a capacity (the size of the array currently allocated) and a max capacity (the maximum size that may be allocated),
which defaults to Integer.MAX_VALUE.
- 
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDefault initial capacity, 128.static final intDeprecated, for removal: This API element is subject to removal in a future version.the growth strategy has changed and doesn't use this constant anymore.Fields inherited from class AbstractList
modCount - 
Constructor Summary
ConstructorsConstructorDescriptionCreates an unbounded instance with default initial capacity.BlockingArrayQueue(int maxCapacity) Creates an instance that does not grow.BlockingArrayQueue(int capacity, int growBy) Deprecated, for removal: This API element is subject to removal in a future version.the growth factor isn't used anymoreBlockingArrayQueue(int capacity, int growBy, int maxCapacity) Deprecated, for removal: This API element is subject to removal in a future version.the growth factor isn't used anymore - 
Method Summary
Modifier and TypeMethodDescriptionvoidbooleanvoidclear()intdrainTo(Collection<? super E> c) intdrainTo(Collection<? super E> c, int maxElements) element()get(int index) intGet the current capacity of this queue.intGet the max capacity of this queue.iterator()listIterator(int index) static <E> BlockingArrayQueue<E> newInstance(int capacity, int maxCapacity) Creates aBlockingArrayQueuewith given initial and max capacities.booleanbooleanpeek()poll()voidintremove()remove(int index) booleanintsize()take()Methods inherited from class AbstractList
addAll, equals, hashCode, indexOf, lastIndexOf, listIterator, removeRange, subListMethods inherited from class AbstractCollection
addAll, contains, containsAll, isEmpty, removeAll, retainAll, toArray, toArray, toStringMethods inherited from interface BlockingQueue
containsMethods inherited from interface Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface List
addAll, addFirst, addLast, contains, containsAll, getFirst, getLast, isEmpty, removeAll, removeFirst, removeLast, replaceAll, retainAll, reversed, sort, spliterator, toArray, toArray 
- 
Field Details
- 
DEFAULT_CAPACITY
public static final int DEFAULT_CAPACITYDefault initial capacity, 128.- See Also:
 
 - 
DEFAULT_GROWTH
Deprecated, for removal: This API element is subject to removal in a future version.the growth strategy has changed and doesn't use this constant anymore.Old default growth factor, 64.- See Also:
 
 
 - 
 - 
Constructor Details
- 
BlockingArrayQueue
public BlockingArrayQueue()Creates an unbounded instance with default initial capacity.- See Also:
 
 - 
BlockingArrayQueue
public BlockingArrayQueue(int maxCapacity) Creates an instance that does not grow. The capacity of the queue is fixed and equal to the given parameter.- Parameters:
 maxCapacity- the maximum capacity
 - 
BlockingArrayQueue
Deprecated, for removal: This API element is subject to removal in a future version.the growth factor isn't used anymoreCreates an unbounded instance.- Parameters:
 capacity- the initial capacitygrowBy- the growth factor
 - 
BlockingArrayQueue
@Deprecated(since="12.1.2", forRemoval=true) public BlockingArrayQueue(int capacity, int growBy, int maxCapacity) Deprecated, for removal: This API element is subject to removal in a future version.the growth factor isn't used anymoreCreates an instance with given initial and max capacities.- Parameters:
 capacity- the initial capacitygrowBy- the growth factormaxCapacity- the maximum capacity
 
 - 
 - 
Method Details
- 
newInstance
Creates aBlockingArrayQueuewith given initial and max capacities.- Parameters:
 capacity- the initial capacitymaxCapacity- the maximum capacity
 - 
clear
public void clear()- Specified by:
 clearin interfaceCollection<E>- Specified by:
 clearin interfaceList<E>- Overrides:
 clearin classAbstractList<E>
 - 
size
public int size()- Specified by:
 sizein interfaceCollection<E>- Specified by:
 sizein interfaceList<E>- Specified by:
 sizein classAbstractCollection<E>
 - 
iterator
 - 
poll
 - 
poll
- Specified by:
 pollin interfaceBlockingQueue<E>- Throws:
 InterruptedException
 - 
peek
 - 
remove
 - 
remove
 - 
remove
- Specified by:
 removein interfaceBlockingQueue<E>- Specified by:
 removein interfaceCollection<E>- Specified by:
 removein interfaceList<E>- Overrides:
 removein classAbstractCollection<E>
 - 
element
 - 
offer
 - 
offer
- Specified by:
 offerin interfaceBlockingQueue<E>- Throws:
 InterruptedException
 - 
add
 - 
add
 - 
put
- Specified by:
 putin interfaceBlockingQueue<E>- Throws:
 InterruptedException
 - 
take
- Specified by:
 takein interfaceBlockingQueue<E>- Throws:
 InterruptedException
 - 
remainingCapacity
public int remainingCapacity()- Specified by:
 remainingCapacityin interfaceBlockingQueue<E>
 - 
drainTo
- Specified by:
 drainToin interfaceBlockingQueue<E>
 - 
drainTo
- Specified by:
 drainToin interfaceBlockingQueue<E>
 - 
get
 - 
set
 - 
listIterator
- Specified by:
 listIteratorin interfaceList<E>- Overrides:
 listIteratorin classAbstractList<E>
 - 
getCapacity
public int getCapacity()Get the current capacity of this queue.- Returns:
 - the current capacity of this queue
 
 - 
getMaxCapacity
public int getMaxCapacity()Get the max capacity of this queue.- Returns:
 - the max capacity of this queue
 
 
 -