Top Description Constructors Methods
com.google.common.collect

public abstract Class ForwardingBlockingDeque<E>

extends ForwardingDeque<E>
implements BlockingDeque<E>
Class Inheritance
All Implemented Interfaces
java.util.concurrent.BlockingDeque, java.util.Deque, java.util.SequencedCollection, java.util.Collection, java.lang.Iterable, java.util.Queue, java.util.concurrent.BlockingQueue
Annotations
@Deprecated
@J2ktIncompatible
@GwtIncompatible
@ElementTypesAreNonnullByDefault
Imports
com.google.common.annotations.GwtIncompatible, .J2ktIncompatible, java.util.Collection, java.util.concurrent.BlockingDeque, .TimeUnit, javax.annotation.CheckForNull

Deprecated

This class has moved to com.google.common.util.concurrent. Please use com.google.common.util.concurrent.ForwardingBlockingDeque instead.

A 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 add alone will not change the behaviour of offer 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.

Author
Emily Soldal
Since
14.0

Constructor Summary

AccessConstructor and Description
protected
ForwardingBlockingDeque()

Constructor for use by subclasses.

Method Summary

Modifier and TypeMethod and Description
protected abstract BlockingDeque<E>
delegate()

Implements abstract com.google.common.collect.ForwardingDeque.delegate.

Returns the backing delegate instance that methods are forwarded to.
public int
drainTo(Collection<? super E>
the collection to transfer elements into
c
)

Implements java.util.concurrent.BlockingQueue.drainTo.

Removes all available elements from this queue and adds them to the given collection.
public int
drainTo(Collection<? super E>
the collection to transfer elements into
c
,
int
the maximum number of elements to transfer
maxElements
)

Implements java.util.concurrent.BlockingQueue.drainTo.

Removes at most the given number of available elements from this queue and adds them to the given collection.
public boolean
offer(E
the element to add
e
,
long
how long to wait before giving up, in units of unit
timeout
,
TimeUnit
a TimeUnit determining how to interpret the timeout parameter
unit
)

Implements java.util.concurrent.BlockingDeque.offer.

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.
public boolean
offerFirst(E
the element to add
e
,
long
how long to wait before giving up, in units of unit
timeout
,
TimeUnit
a TimeUnit determining how to interpret the timeout parameter
unit
)

Implements java.util.concurrent.BlockingDeque.offerFirst.

Inserts the specified element at the front of this deque, waiting up to the specified wait time if necessary for space to become available.
public boolean
offerLast(E
the element to add
e
,
long
how long to wait before giving up, in units of unit
timeout
,
TimeUnit
a TimeUnit determining how to interpret the timeout parameter
unit
)

Implements java.util.concurrent.BlockingDeque.offerLast.

Inserts the specified element at the end of this deque, waiting up to the specified wait time if necessary for space to become available.
public E
poll(long
how long to wait before giving up, in units of unit
timeout
,
TimeUnit
a TimeUnit determining how to interpret the timeout parameter
unit
)

Implements java.util.concurrent.BlockingDeque.poll.

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.
public E
pollFirst(long
how long to wait before giving up, in units of unit
timeout
,
TimeUnit
a TimeUnit determining how to interpret the timeout parameter
unit
)

Implements java.util.concurrent.BlockingDeque.pollFirst.

Retrieves and removes the first element of this deque, waiting up to the specified wait time if necessary for an element to become available.
public E
pollLast(long
how long to wait before giving up, in units of unit
timeout
,
TimeUnit
a TimeUnit determining how to interpret the timeout parameter
unit
)

Implements java.util.concurrent.BlockingDeque.pollLast.

Retrieves and removes the last element of this deque, waiting up to the specified wait time if necessary for an element to become available.
public void
put(E
the element to add
e
)

Implements java.util.concurrent.BlockingDeque.put.

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.
public void
putFirst(E
the element to add
e
)

Implements java.util.concurrent.BlockingDeque.putFirst.

Inserts the specified element at the front of this deque, waiting if necessary for space to become available.
public void
putLast(E
the element to add
e
)

Implements java.util.concurrent.BlockingDeque.putLast.

Inserts the specified element at the end of this deque, waiting if necessary for space to become available.
public int
remainingCapacity()

Implements java.util.concurrent.BlockingQueue.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.
public E
take()

Implements java.util.concurrent.BlockingDeque.take.

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.
public E
takeFirst()

Implements java.util.concurrent.BlockingDeque.takeFirst.

Retrieves and removes the first element of this deque, waiting if necessary until an element becomes available.
public E
takeLast()

Implements java.util.concurrent.BlockingDeque.takeLast.

Retrieves and removes the last element of this deque, waiting if necessary until an element becomes available.
Inherited from com.google.common.collect.ForwardingDeque:
addFirstaddLastdescendingIteratorgetFirstgetLastofferFirstofferLastpeekFirstpeekLastpollFirstpollLastpoppushremoveFirstremoveFirstOccurrenceremoveLastremoveLastOccurrence

Constructor Detail

ForwardingBlockingDequeback to summary
protected ForwardingBlockingDeque()

Constructor for use by subclasses.

Method Detail

delegateback to summary
protected abstract BlockingDeque<E> delegate()

Implements abstract com.google.common.collect.ForwardingDeque.delegate.

Doc from com.google.common.collect.ForwardingObject.delegate.

Returns the backing delegate instance that methods are forwarded to. Abstract subclasses generally override this method with an abstract method that has a more specific return type, such as ForwardingSet#delegate. Concrete subclasses override this method to supply the instance being decorated.

Annotations
@Override
drainToback to summary
public int drainTo(Collection<? super E> c)

Implements java.util.concurrent.BlockingQueue.drainTo.

Doc from java.util.concurrent.BlockingQueue.drainTo.

Removes all available elements from this queue and adds them to the given collection. This operation may be more efficient than repeatedly polling this queue. A failure encountered while attempting to add elements to collection 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.

Parameters
c:Collection<? super E>

the collection to transfer elements into

Returns:int

the number of elements transferred

Annotations
@Override
drainToback to summary
public int drainTo(Collection<? super E> c, int maxElements)

Implements java.util.concurrent.BlockingQueue.drainTo.

Doc from java.util.concurrent.BlockingQueue.drainTo.

Removes at most the given number of available elements from this queue and adds them to the given collection. A failure encountered while attempting to add elements to collection 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.

Parameters
c:Collection<? super E>

the collection to transfer elements into

maxElements:int

the maximum number of elements to transfer

Returns:int

the number of elements transferred

Annotations
@Override
offerback to summary
public boolean offer(E e, long timeout, TimeUnit unit) throws InterruptedException

Implements java.util.concurrent.BlockingDeque.offer.

Doc from java.util.concurrent.BlockingDeque.offer.

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.

This method is equivalent to offerLast.

Parameters
e:E

the element to add

timeout:long

Doc from java.util.concurrent.BlockingQueue.offer.

how long to wait before giving up, in units of unit

unit:TimeUnit

Doc from java.util.concurrent.BlockingQueue.offer.

a TimeUnit determining how to interpret the timeout parameter

Returns:boolean

true if the element was added to this deque, else false

Annotations
@Override
Exceptions
InterruptedException:
if interrupted while waiting
offerFirstback to summary
public boolean offerFirst(E e, long timeout, TimeUnit unit) throws InterruptedException

Implements java.util.concurrent.BlockingDeque.offerFirst.

Doc from java.util.concurrent.BlockingDeque.offerFirst.

Inserts the specified element at the front of this deque, waiting up to the specified wait time if necessary for space to become available.

Parameters
e:E

the element to add

timeout:long

how long to wait before giving up, in units of unit

unit:TimeUnit

a TimeUnit determining how to interpret the timeout parameter

Returns:boolean

true if successful, or false if the specified waiting time elapses before space is available

Annotations
@Override
Exceptions
InterruptedException:
if interrupted while waiting
offerLastback to summary
public boolean offerLast(E e, long timeout, TimeUnit unit) throws InterruptedException

Implements java.util.concurrent.BlockingDeque.offerLast.

Doc from java.util.concurrent.BlockingDeque.offerLast.

Inserts the specified element at the end of this deque, waiting up to the specified wait time if necessary for space to become available.

Parameters
e:E

the element to add

timeout:long

how long to wait before giving up, in units of unit

unit:TimeUnit

a TimeUnit determining how to interpret the timeout parameter

Returns:boolean

true if successful, or false if the specified waiting time elapses before space is available

Annotations
@Override
Exceptions
InterruptedException:
if interrupted while waiting
pollback to summary
public E poll(long timeout, TimeUnit unit) throws InterruptedException

Implements java.util.concurrent.BlockingDeque.poll.

Doc from java.util.concurrent.BlockingDeque.poll.

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.

This method is equivalent to pollFirst.

Parameters
timeout:long

Doc from java.util.concurrent.BlockingQueue.poll.

how long to wait before giving up, in units of unit

unit:TimeUnit

Doc from java.util.concurrent.BlockingQueue.poll.

a TimeUnit determining how to interpret the timeout parameter

Returns:E

the head of this deque, or null if the specified waiting time elapses before an element is available

Annotations
@Override
@CheckForNull
Exceptions
InterruptedException:
if interrupted while waiting
pollFirstback to summary
public E pollFirst(long timeout, TimeUnit unit) throws InterruptedException

Implements java.util.concurrent.BlockingDeque.pollFirst.

Doc from java.util.concurrent.BlockingDeque.pollFirst.

Retrieves and removes the first element of this deque, waiting up to the specified wait time if necessary for an element to become available.

Parameters
timeout:long

how long to wait before giving up, in units of unit

unit:TimeUnit

a TimeUnit determining how to interpret the timeout parameter

Returns:E

the head of this deque, or null if the specified waiting time elapses before an element is available

Annotations
@Override
@CheckForNull
Exceptions
InterruptedException:
if interrupted while waiting
pollLastback to summary
public E pollLast(long timeout, TimeUnit unit) throws InterruptedException

Implements java.util.concurrent.BlockingDeque.pollLast.

Doc from java.util.concurrent.BlockingDeque.pollLast.

Retrieves and removes the last element of this deque, waiting up to the specified wait time if necessary for an element to become available.

Parameters
timeout:long

how long to wait before giving up, in units of unit

unit:TimeUnit

a TimeUnit determining how to interpret the timeout parameter

Returns:E

the tail of this deque, or null if the specified waiting time elapses before an element is available

Annotations
@Override
@CheckForNull
Exceptions
InterruptedException:
if interrupted while waiting
putback to summary
public void put(E e) throws InterruptedException

Implements java.util.concurrent.BlockingDeque.put.

Doc from java.util.concurrent.BlockingDeque.put.

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.

This method is equivalent to putLast.

Parameters
e:E

the element to add

Annotations
@Override
Exceptions
InterruptedException:
if interrupted while waiting
putFirstback to summary
public void putFirst(E e) throws InterruptedException

Implements java.util.concurrent.BlockingDeque.putFirst.

Doc from java.util.concurrent.BlockingDeque.putFirst.

Inserts the specified element at the front of this deque, waiting if necessary for space to become available.

Parameters
e:E

the element to add

Annotations
@Override
Exceptions
InterruptedException:
if interrupted while waiting
putLastback to summary
public void putLast(E e) throws InterruptedException

Implements java.util.concurrent.BlockingDeque.putLast.

Doc from java.util.concurrent.BlockingDeque.putLast.

Inserts the specified element at the end of this deque, waiting if necessary for space to become available.

Parameters
e:E

the element to add

Annotations
@Override
Exceptions
InterruptedException:
if interrupted while waiting
remainingCapacityback to summary
public int remainingCapacity()

Implements java.util.concurrent.BlockingQueue.remainingCapacity.

Doc from java.util.concurrent.BlockingQueue.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.

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.

Returns:int

the remaining capacity

Annotations
@Override
takeback to summary
public E take() throws InterruptedException

Implements java.util.concurrent.BlockingDeque.take.

Doc from java.util.concurrent.BlockingDeque.take.

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.

This method is equivalent to takeFirst.

Returns:E

the head of this deque

Annotations
@Override
Exceptions
InterruptedException:
if interrupted while waiting
takeFirstback to summary
public E takeFirst() throws InterruptedException

Implements java.util.concurrent.BlockingDeque.takeFirst.

Doc from java.util.concurrent.BlockingDeque.takeFirst.

Retrieves and removes the first element of this deque, waiting if necessary until an element becomes available.

Returns:E

the head of this deque

Annotations
@Override
Exceptions
InterruptedException:
if interrupted while waiting
takeLastback to summary
public E takeLast() throws InterruptedException

Implements java.util.concurrent.BlockingDeque.takeLast.

Doc from java.util.concurrent.BlockingDeque.takeLast.

Retrieves and removes the last element of this deque, waiting if necessary until an element becomes available.

Returns:E

the tail of this deque

Annotations
@Override
Exceptions
InterruptedException:
if interrupted while waiting