org.eclipse.jetty.util
E
- The element typepublic class BlockingArrayQueue<E> extends java.util.AbstractList<E> implements java.util.concurrent.BlockingQueue<E>
BlockingQueue
, specifically the take()
and
poll(long, TimeUnit)
methods.
Unlike ArrayBlockingQueue
, this class is
able to grow and provides a blocking put call.
The queue has both a capacity (the size of the array currently allocated)
and a limit (the maximum size that may be allocated), which defaults to
Integer.MAX_VALUE
.
Modifier and Type | Field and Description |
---|---|
int |
DEFAULT_CAPACITY |
int |
DEFAULT_GROWTH |
Constructor and Description |
---|
BlockingArrayQueue()
Create a growing partially blocking Queue
|
BlockingArrayQueue(int limit)
Create a fixed size partially blocking Queue
|
BlockingArrayQueue(int capacity,
int growBy)
Create a growing partially blocking Queue.
|
BlockingArrayQueue(int capacity,
int growBy,
int limit)
Create a growing limited partially blocking Queue.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(E e) |
void |
add(int index,
E e) |
void |
clear() |
int |
drainTo(java.util.Collection<? super E> c) |
int |
drainTo(java.util.Collection<? super E> c,
int maxElements) |
E |
element() |
E |
get(int index) |
int |
getCapacity() |
int |
getLimit() |
boolean |
isEmpty() |
boolean |
offer(E e) |
boolean |
offer(E o,
long timeout,
java.util.concurrent.TimeUnit unit) |
E |
peek() |
E |
poll() |
E |
poll(long time,
java.util.concurrent.TimeUnit unit)
Retrieves and removes the head of this queue, waiting
if necessary up to the specified wait time if no elements are
present on this queue.
|
void |
put(E o) |
int |
remainingCapacity() |
E |
remove() |
E |
remove(int index) |
E |
set(int index,
E e) |
int |
size() |
E |
take()
Retrieves and removes the head of this queue, waiting
if no elements are present on this queue.
|
addAll, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, removeRange, subList
addAll, contains, containsAll, remove, removeAll, retainAll, toArray, toArray, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
public final int DEFAULT_CAPACITY
public final int DEFAULT_GROWTH
public BlockingArrayQueue()
public BlockingArrayQueue(int limit)
limit
- The initial capacity and the limit.public BlockingArrayQueue(int capacity, int growBy)
capacity
- Initial capacitygrowBy
- Incremental capacity.public BlockingArrayQueue(int capacity, int growBy, int limit)
capacity
- Initial capacitygrowBy
- Incremental capacity.limit
- maximum capacity.public int getCapacity()
public int getLimit()
public boolean add(E e)
public boolean offer(E e)
public E take() throws java.lang.InterruptedException
take
in interface java.util.concurrent.BlockingQueue<E>
java.lang.InterruptedException
- if interrupted while waiting.public E poll(long time, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
poll
in interface java.util.concurrent.BlockingQueue<E>
time
- how long to wait before giving up, in units of
unitunit
- a TimeUnit determining how to interpret the
timeout parameterjava.lang.InterruptedException
- if interrupted while waiting.public void clear()
public boolean isEmpty()
public int size()
public E get(int index)
public E remove(int index)
public void add(int index, E e)
public int drainTo(java.util.Collection<? super E> c)
drainTo
in interface java.util.concurrent.BlockingQueue<E>
public int drainTo(java.util.Collection<? super E> c, int maxElements)
drainTo
in interface java.util.concurrent.BlockingQueue<E>
public boolean offer(E o, long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
offer
in interface java.util.concurrent.BlockingQueue<E>
java.lang.InterruptedException
public void put(E o) throws java.lang.InterruptedException
put
in interface java.util.concurrent.BlockingQueue<E>
java.lang.InterruptedException
public int remainingCapacity()
remainingCapacity
in interface java.util.concurrent.BlockingQueue<E>
Copyright © 2017. All Rights Reserved.