|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.util.AbstractCollection<E> java.util.AbstractList<E> org.eclipse.jetty.util.BlockingArrayQueue<E>
E
- The element typepublic class BlockingArrayQueue<E>
Queue backed by a circular array.
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. This queue also has a partial implementation of
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
.
Field Summary | |
---|---|
int |
DEFAULT_CAPACITY
|
int |
DEFAULT_GROWTH
|
Fields inherited from class java.util.AbstractList |
---|
modCount |
Constructor Summary | |
---|---|
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. |
Method Summary | |
---|---|
boolean |
add(E e)
|
void |
add(int index,
E e)
|
void |
clear()
|
int |
drainTo(Collection<? super E> c)
|
int |
drainTo(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,
TimeUnit unit)
|
E |
peek()
|
E |
poll()
|
E |
poll(long time,
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. |
Methods inherited from class java.util.AbstractList |
---|
addAll, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, removeRange, subList |
Methods inherited from class java.util.AbstractCollection |
---|
addAll, contains, containsAll, remove, removeAll, retainAll, toArray, toArray, toString |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Collection |
---|
addAll, contains, containsAll, equals, hashCode, iterator, remove, removeAll, retainAll, toArray, toArray |
Methods inherited from interface java.util.List |
---|
addAll, contains, containsAll, remove, removeAll, retainAll, toArray, toArray |
Field Detail |
---|
public final int DEFAULT_CAPACITY
public final int DEFAULT_GROWTH
Constructor Detail |
---|
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.Method Detail |
---|
public int getCapacity()
public int getLimit()
public boolean add(E e)
add
in interface Collection<E>
add
in interface BlockingQueue<E>
add
in interface List<E>
add
in class AbstractList<E>
public E element()
element
in interface Queue<E>
public E peek()
peek
in interface Queue<E>
public boolean offer(E e)
offer
in interface BlockingQueue<E>
offer
in interface Queue<E>
public E poll()
poll
in interface Queue<E>
public E take() throws InterruptedException
take
in interface BlockingQueue<E>
InterruptedException
- if interrupted while waiting.public E poll(long time, TimeUnit unit) throws InterruptedException
poll
in interface BlockingQueue<E>
time
- how long to wait before giving up, in units of
unitunit
- a TimeUnit determining how to interpret the
timeout parameter
InterruptedException
- if interrupted while waiting.public E remove()
remove
in interface Queue<E>
public void clear()
clear
in interface Collection<E>
clear
in interface List<E>
clear
in class AbstractList<E>
public boolean isEmpty()
isEmpty
in interface Collection<E>
isEmpty
in interface List<E>
isEmpty
in class AbstractCollection<E>
public int size()
size
in interface Collection<E>
size
in interface List<E>
size
in class AbstractCollection<E>
public E get(int index)
get
in interface List<E>
get
in class AbstractList<E>
public E remove(int index)
remove
in interface List<E>
remove
in class AbstractList<E>
public E set(int index, E e)
set
in interface List<E>
set
in class AbstractList<E>
public void add(int index, E e)
add
in interface List<E>
add
in class AbstractList<E>
public int drainTo(Collection<? super E> c)
drainTo
in interface BlockingQueue<E>
public int drainTo(Collection<? super E> c, int maxElements)
drainTo
in interface BlockingQueue<E>
public boolean offer(E o, long timeout, TimeUnit unit) throws InterruptedException
offer
in interface BlockingQueue<E>
InterruptedException
public void put(E o) throws InterruptedException
put
in interface BlockingQueue<E>
InterruptedException
public int remainingCapacity()
remainingCapacity
in interface BlockingQueue<E>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |