com.google.common.util.concurrent
. Please use ForwardingBlockingDeque
instead.@Deprecated @GwtIncompatible public abstract class ForwardingBlockingDeque<E> extends ForwardingDeque<E> implements BlockingDeque<E>
BlockingDeque
which forwards all its method calls to another BlockingDeque
.
Subclasses should override one or more methods to modify the behavior of the backing deque as
desired per the decorator pattern.
Warning: The methods of ForwardingBlockingDeque
forward indiscriminately
to the methods of the delegate. For example, overriding ForwardingCollection.add(E)
alone will not change
the behaviour of offer(E, long, java.util.concurrent.TimeUnit)
which can lead to unexpected behaviour. In this case, you should
override offer
as well, either providing your own implementation, or delegating to the
provided standardOffer
method.
default
method warning: This class does not forward calls to default
methods. Instead, it inherits their default implementations. When those implementations
invoke methods, they invoke methods on the ForwardingBlockingDeque
.
The standard
methods are not guaranteed to be thread-safe, even when all of the
methods that they depend on are thread-safe.
Modifier | Constructor and Description |
---|---|
protected |
ForwardingBlockingDeque()
Deprecated.
Constructor for use by subclasses.
|
Modifier and Type | Method and Description |
---|---|
protected abstract BlockingDeque<E> |
delegate()
Deprecated.
Returns the backing delegate instance that methods are forwarded to.
|
int |
drainTo(Collection<? super E> c)
Deprecated.
Removes all available elements from this queue and adds them
to the given collection.
|
int |
drainTo(Collection<? super E> c,
int maxElements)
Deprecated.
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)
Deprecated.
Inserts the specified element into the queue represented by this deque
(in other words, at the tail of this deque), waiting up to the
specified wait time if necessary for space to become available.
|
boolean |
offerFirst(E e,
long timeout,
TimeUnit unit)
Deprecated.
Inserts the specified element at the front of this deque,
waiting up to the specified wait time if necessary for space to
become available.
|
boolean |
offerLast(E e,
long timeout,
TimeUnit unit)
Deprecated.
Inserts the specified element at the end of this deque,
waiting up to the specified wait time if necessary for space to
become available.
|
E |
poll(long timeout,
TimeUnit unit)
Deprecated.
Retrieves and removes the head of the queue represented by this deque
(in other words, the first element of this deque), waiting up to the
specified wait time if necessary for an element to become available.
|
E |
pollFirst(long timeout,
TimeUnit unit)
Deprecated.
Retrieves and removes the first element of this deque, waiting
up to the specified wait time if necessary for an element to
become available.
|
E |
pollLast(long timeout,
TimeUnit unit)
Deprecated.
Retrieves and removes the last element of this deque, waiting
up to the specified wait time if necessary for an element to
become available.
|
void |
put(E e)
Deprecated.
Inserts the specified element into the queue represented by this deque
(in other words, at the tail of this deque), waiting if necessary for
space to become available.
|
void |
putFirst(E e)
Deprecated.
Inserts the specified element at the front of this deque,
waiting if necessary for space to become available.
|
void |
putLast(E e)
Deprecated.
Inserts the specified element at the end of this deque,
waiting if necessary for space to become available.
|
int |
remainingCapacity()
Deprecated.
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()
Deprecated.
Retrieves and removes the head of the queue represented by this deque
(in other words, the first element of this deque), waiting if
necessary until an element becomes available.
|
E |
takeFirst()
Deprecated.
Retrieves and removes the first element of this deque, waiting
if necessary until an element becomes available.
|
E |
takeLast()
Deprecated.
Retrieves and removes the last element of this deque, waiting
if necessary until an element becomes available.
|
addFirst, addLast, descendingIterator, getFirst, getLast, offerFirst, offerLast, peekFirst, peekLast, pollFirst, pollLast, pop, push, removeFirst, removeFirstOccurrence, removeLast, removeLastOccurrence
element, offer, peek, poll, remove, standardOffer, standardPeek, standardPoll
add, addAll, clear, contains, containsAll, isEmpty, iterator, remove, removeAll, retainAll, size, standardAddAll, standardClear, standardContains, standardContainsAll, standardIsEmpty, standardRemove, standardRemoveAll, standardRetainAll, standardToArray, standardToArray, standardToString, toArray, toArray
toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
add, addFirst, addLast, contains, element, iterator, offer, offerFirst, offerLast, peek, poll, push, remove, remove, removeFirstOccurrence, removeLastOccurrence, size
descendingIterator, getFirst, getLast, peekFirst, peekLast, pollFirst, pollLast, pop, removeFirst, removeLast
addAll, clear, containsAll, equals, hashCode, isEmpty, parallelStream, removeAll, removeIf, retainAll, spliterator, stream, toArray, toArray
protected ForwardingBlockingDeque()
protected abstract BlockingDeque<E> delegate()
ForwardingObject
ForwardingSet.delegate()
. Concrete subclasses override this method to supply the
instance being decorated.delegate
in class ForwardingDeque<E>
public int remainingCapacity()
java.util.concurrent.BlockingQueue
Integer.MAX_VALUE
if there is no intrinsic
limit.
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 void putFirst(E e) throws InterruptedException
java.util.concurrent.BlockingDeque
putFirst
in interface BlockingDeque<E>
e
- the element to addInterruptedException
- if interrupted while waitingpublic void putLast(E e) throws InterruptedException
java.util.concurrent.BlockingDeque
putLast
in interface BlockingDeque<E>
e
- the element to addInterruptedException
- if interrupted while waitingpublic boolean offerFirst(E e, long timeout, TimeUnit unit) throws InterruptedException
java.util.concurrent.BlockingDeque
offerFirst
in interface BlockingDeque<E>
e
- the element to addtimeout
- how long to wait before giving up, in units of
unit
unit
- a TimeUnit
determining how to interpret the
timeout
parametertrue
if successful, or false
if
the specified waiting time elapses before space is availableInterruptedException
- if interrupted while waitingpublic boolean offerLast(E e, long timeout, TimeUnit unit) throws InterruptedException
java.util.concurrent.BlockingDeque
offerLast
in interface BlockingDeque<E>
e
- the element to addtimeout
- how long to wait before giving up, in units of
unit
unit
- a TimeUnit
determining how to interpret the
timeout
parametertrue
if successful, or false
if
the specified waiting time elapses before space is availableInterruptedException
- if interrupted while waitingpublic E takeFirst() throws InterruptedException
java.util.concurrent.BlockingDeque
takeFirst
in interface BlockingDeque<E>
InterruptedException
- if interrupted while waitingpublic E takeLast() throws InterruptedException
java.util.concurrent.BlockingDeque
takeLast
in interface BlockingDeque<E>
InterruptedException
- if interrupted while waitingpublic E pollFirst(long timeout, TimeUnit unit) throws InterruptedException
java.util.concurrent.BlockingDeque
pollFirst
in interface BlockingDeque<E>
timeout
- how long to wait before giving up, in units of
unit
unit
- a TimeUnit
determining how to interpret the
timeout
parameternull
if the specified
waiting time elapses before an element is availableInterruptedException
- if interrupted while waitingpublic E pollLast(long timeout, TimeUnit unit) throws InterruptedException
java.util.concurrent.BlockingDeque
pollLast
in interface BlockingDeque<E>
timeout
- how long to wait before giving up, in units of
unit
unit
- a TimeUnit
determining how to interpret the
timeout
parameternull
if the specified
waiting time elapses before an element is availableInterruptedException
- if interrupted while waitingpublic void put(E e) throws InterruptedException
java.util.concurrent.BlockingDeque
This method is equivalent to putLast
.
put
in interface BlockingDeque<E>
put
in interface BlockingQueue<E>
e
- the element to addInterruptedException
- if interrupted while waitingpublic boolean offer(E e, long timeout, TimeUnit unit) throws InterruptedException
java.util.concurrent.BlockingDeque
This method is equivalent to
offerLast
.
offer
in interface BlockingDeque<E>
offer
in interface BlockingQueue<E>
e
- the element to addtimeout
- how long to wait before giving up, in units of
unit
unit
- a TimeUnit
determining how to interpret the
timeout
parametertrue
if the element was added to this deque, else
false
InterruptedException
- if interrupted while waitingpublic E take() throws InterruptedException
java.util.concurrent.BlockingDeque
This method is equivalent to takeFirst
.
take
in interface BlockingDeque<E>
take
in interface BlockingQueue<E>
InterruptedException
- if interrupted while waitingpublic E poll(long timeout, TimeUnit unit) throws InterruptedException
java.util.concurrent.BlockingDeque
This method is equivalent to
pollFirst
.
poll
in interface BlockingDeque<E>
poll
in interface BlockingQueue<E>
timeout
- how long to wait before giving up, in units of
unit
unit
- a TimeUnit
determining how to interpret the
timeout
parameternull
if the
specified waiting time elapses before an element is availableInterruptedException
- if interrupted while waitingpublic int drainTo(Collection<? super E> c)
java.util.concurrent.BlockingQueue
c
may result in elements being in neither,
either or both collections when the associated exception is
thrown. Attempts to drain a queue to itself result in
IllegalArgumentException
. Further, the behavior of
this operation is undefined if the specified collection is
modified while the operation is in progress.drainTo
in interface BlockingQueue<E>
c
- the collection to transfer elements intopublic int drainTo(Collection<? super E> c, int maxElements)
java.util.concurrent.BlockingQueue
c
may result in elements being in neither,
either or both collections when the associated exception is
thrown. Attempts to drain a queue to itself result in
IllegalArgumentException
. Further, the behavior of
this operation is undefined if the specified collection is
modified while the operation is in progress.drainTo
in interface BlockingQueue<E>
c
- the collection to transfer elements intomaxElements
- the maximum number of elements to transferCopyright © 2010–2017. All rights reserved.