Class ForwardingBlockingDeque<E>

  • All Implemented Interfaces:
    Iterable<E>, Collection<E>, BlockingDeque<E>, BlockingQueue<E>, Deque<E>, Queue<E>

    @Deprecated
    @GwtIncompatible
    public abstract class ForwardingBlockingDeque<E>
    extends ForwardingDeque<E>
    implements BlockingDeque<E>
    Deprecated.
    This class has moved to com.google.common.util.concurrent. Please use 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 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.

    Since:
    14.0
    Author:
    Emily Soldal
    • Constructor Detail

    • Method Detail

      • delegate

        protected abstract BlockingDeque<Edelegate()
        Deprecated.
        Description copied from class: ForwardingObject
        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.
        Specified by:
        delegate in class ForwardingDeque<E>
      • remainingCapacity

        public int remainingCapacity()
        Deprecated.
        Description copied from interface: java.util.concurrent.BlockingQueue
        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.

        Specified by:
        remainingCapacity in interface BlockingQueue<E>
        Returns:
        the remaining capacity
      • offerFirst

        public boolean offerFirst​(E e,
                                  long timeout,
                                  TimeUnit unit)
                           throws InterruptedException
        Deprecated.
        Description copied from interface: java.util.concurrent.BlockingDeque
        Inserts the specified element at the front of this deque, waiting up to the specified wait time if necessary for space to become available.
        Specified by:
        offerFirst in interface BlockingDeque<E>
        Parameters:
        e - the element to add
        timeout - how long to wait before giving up, in units of unit
        unit - a TimeUnit determining how to interpret the timeout parameter
        Returns:
        true if successful, or false if the specified waiting time elapses before space is available
        Throws:
        InterruptedException - if interrupted while waiting
      • offerLast

        public boolean offerLast​(E e,
                                 long timeout,
                                 TimeUnit unit)
                          throws InterruptedException
        Deprecated.
        Description copied from interface: java.util.concurrent.BlockingDeque
        Inserts the specified element at the end of this deque, waiting up to the specified wait time if necessary for space to become available.
        Specified by:
        offerLast in interface BlockingDeque<E>
        Parameters:
        e - the element to add
        timeout - how long to wait before giving up, in units of unit
        unit - a TimeUnit determining how to interpret the timeout parameter
        Returns:
        true if successful, or false if the specified waiting time elapses before space is available
        Throws:
        InterruptedException - if interrupted while waiting
      • pollFirst

        @CheckForNull
        public E pollFirst​(long timeout,
                           TimeUnit unit)
                    throws InterruptedException
        Deprecated.
        Description copied from interface: java.util.concurrent.BlockingDeque
        Retrieves and removes the first element of this deque, waiting up to the specified wait time if necessary for an element to become available.
        Specified by:
        pollFirst in interface BlockingDeque<E>
        Parameters:
        timeout - how long to wait before giving up, in units of unit
        unit - a TimeUnit determining how to interpret the timeout parameter
        Returns:
        the head of this deque, or null if the specified waiting time elapses before an element is available
        Throws:
        InterruptedException - if interrupted while waiting
      • pollLast

        @CheckForNull
        public E pollLast​(long timeout,
                          TimeUnit unit)
                   throws InterruptedException
        Deprecated.
        Description copied from interface: java.util.concurrent.BlockingDeque
        Retrieves and removes the last element of this deque, waiting up to the specified wait time if necessary for an element to become available.
        Specified by:
        pollLast in interface BlockingDeque<E>
        Parameters:
        timeout - how long to wait before giving up, in units of unit
        unit - a TimeUnit determining how to interpret the timeout parameter
        Returns:
        the tail of this deque, or null if the specified waiting time elapses before an element is available
        Throws:
        InterruptedException - if interrupted while waiting
      • offer

        public boolean offer​(E e,
                             long timeout,
                             TimeUnit unit)
                      throws InterruptedException
        Deprecated.
        Description copied from interface: java.util.concurrent.BlockingDeque
        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.

        Specified by:
        offer in interface BlockingDeque<E>
        Specified by:
        offer in interface BlockingQueue<E>
        Parameters:
        e - the element to add
        timeout - how long to wait before giving up, in units of unit
        unit - a TimeUnit determining how to interpret the timeout parameter
        Returns:
        true if the element was added to this deque, else false
        Throws:
        InterruptedException - if interrupted while waiting
      • poll

        @CheckForNull
        public E poll​(long timeout,
                      TimeUnit unit)
               throws InterruptedException
        Deprecated.
        Description copied from interface: java.util.concurrent.BlockingDeque
        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.

        Specified by:
        poll in interface BlockingDeque<E>
        Specified by:
        poll in interface BlockingQueue<E>
        Parameters:
        timeout - how long to wait before giving up, in units of unit
        unit - a TimeUnit determining how to interpret the timeout parameter
        Returns:
        the head of this deque, or null if the specified waiting time elapses before an element is available
        Throws:
        InterruptedException - if interrupted while waiting
      • drainTo

        public int drainTo​(Collection<? super E> c)
        Deprecated.
        Description copied from interface: java.util.concurrent.BlockingQueue
        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.
        Specified by:
        drainTo in interface BlockingQueue<E>
        Parameters:
        c - the collection to transfer elements into
        Returns:
        the number of elements transferred
      • drainTo

        public int drainTo​(Collection<? super E> c,
                           int maxElements)
        Deprecated.
        Description copied from interface: java.util.concurrent.BlockingQueue
        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.
        Specified by:
        drainTo in interface BlockingQueue<E>
        Parameters:
        c - the collection to transfer elements into
        maxElements - the maximum number of elements to transfer
        Returns:
        the number of elements transferred