|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.google.common.collect.ForwardingObject com.google.common.collect.ForwardingCollection<E> com.google.common.collect.ForwardingQueue<E> com.google.common.util.concurrent.ForwardingBlockingQueue<E>
E
- the type of elements held in this collectionpublic abstract class ForwardingBlockingQueue<E>
A BlockingQueue
which forwards all its method calls to another
BlockingQueue
. Subclasses should override one or more methods to
modify the behavior of the backing collection as desired per the decorator pattern.
Constructor Summary | |
---|---|
protected |
ForwardingBlockingQueue()
Constructor for use by subclasses. |
Method Summary | |
---|---|
protected abstract BlockingQueue<E> |
delegate()
Returns the backing delegate instance that methods are forwarded to. |
int |
drainTo(Collection<? super E> c)
Removes all available elements from this queue and adds them to the given collection. |
int |
drainTo(Collection<? super E> c,
int maxElements)
Removes at most the given number of available elements from this queue and adds them to the given collection. |
boolean |
offer(E e,
long timeout,
TimeUnit unit)
Inserts the specified element into this queue, waiting up to the specified wait time if necessary for space to become available. |
E |
poll(long timeout,
TimeUnit unit)
Retrieves and removes the head of this queue, waiting up to the specified wait time if necessary for an element to become available. |
void |
put(E e)
Inserts the specified element into this queue, waiting if necessary for space to become available. |
int |
remainingCapacity()
Returns the number of additional elements that this queue can ideally (in the absence of memory or resource constraints) accept without blocking, or Integer.MAX_VALUE if there is no intrinsic limit. |
E |
take()
Retrieves and removes the head of this queue, waiting if necessary until an element becomes available. |
Methods inherited from class com.google.common.collect.ForwardingQueue |
---|
element, offer, peek, poll, remove |
Methods inherited from class com.google.common.collect.ForwardingCollection |
---|
add, addAll, clear, contains, containsAll, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray |
Methods inherited from class com.google.common.collect.ForwardingObject |
---|
toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.concurrent.BlockingQueue |
---|
add, contains, offer, remove |
Methods inherited from interface java.util.Queue |
---|
element, peek, poll, remove |
Methods inherited from interface java.util.Collection |
---|
addAll, clear, containsAll, equals, hashCode, isEmpty, iterator, removeAll, retainAll, size, toArray, toArray |
Constructor Detail |
---|
protected ForwardingBlockingQueue()
Method Detail |
---|
protected abstract BlockingQueue<E> delegate()
ForwardingObject
ForwardingSet.delegate()
. Concrete subclasses override this method to supply
the instance being decorated.
delegate
in class ForwardingQueue<E>
public int drainTo(Collection<? super E> c, int maxElements)
java.util.concurrent.BlockingQueue
drainTo
in interface BlockingQueue<E>
c
- the collection to transfer elements intomaxElements
- the maximum number of elements to transfer
public int drainTo(Collection<? super E> c)
java.util.concurrent.BlockingQueue
drainTo
in interface BlockingQueue<E>
c
- the collection to transfer elements into
public boolean offer(E e, long timeout, TimeUnit unit) throws InterruptedException
java.util.concurrent.BlockingQueue
offer
in interface BlockingQueue<E>
e
- the element to addtimeout
- how long to wait before giving up, in units of
unitunit
- a TimeUnit determining how to interpret the
timeout parameter
InterruptedException
- if interrupted while waitingpublic E poll(long timeout, TimeUnit unit) throws InterruptedException
java.util.concurrent.BlockingQueue
poll
in interface BlockingQueue<E>
timeout
- how long to wait before giving up, in units of
unitunit
- a TimeUnit determining how to interpret the
timeout parameter
InterruptedException
- if interrupted while waitingpublic void put(E e) throws InterruptedException
java.util.concurrent.BlockingQueue
put
in interface BlockingQueue<E>
e
- the element to add
InterruptedException
- if interrupted while waitingpublic int remainingCapacity()
java.util.concurrent.BlockingQueue
Note that you cannot always tell if an attempt to insert an element will succeed by inspecting remainingCapacity because it may be the case that another thread is about to insert or remove an element.
remainingCapacity
in interface BlockingQueue<E>
public E take() throws InterruptedException
java.util.concurrent.BlockingQueue
take
in interface BlockingQueue<E>
InterruptedException
- if interrupted while waiting
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |