org.eclipse.jetty.util

## Class BlockingArrayQueue<E>

- java.lang.Object
- - java.util.AbstractCollection<E>
  - - java.util.AbstractList<E>
    - - org.eclipse.jetty.util.BlockingArrayQueue<E>

- Type Parameters:
    `E` - The element type
  All Implemented Interfaces:
    java.lang.Iterable<E>, java.util.Collection<E>, java.util.concurrent.BlockingQueue<E>, java.util.List<E>, java.util.Queue<E>

      public class BlockingArrayQueue<E>
      extends java.util.AbstractList<E>
      implements java.util.concurrent.BlockingQueue<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

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `int` | `DEFAULT_CAPACITY`
    `int` | `DEFAULT_GROWTH`

    - ### Fields inherited from class java.util.AbstractList

      `modCount`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `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

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `add(E e)`
    `void` | `add(int index, E e)`
    `void` | `clear()`
    `int` | `drainTo(java.util.Collection<? super E> c)`
    `int` | `drainTo(java.util.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, java.util.concurrent.TimeUnit unit)`
    `E` | `peek()`
    `E` | `poll()`
    `E` | `poll(long time, java.util.concurrent.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.concurrent.BlockingQueue

      `contains, remove`

    - ### Methods inherited from interface java.util.Collection

      `addAll, containsAll, equals, hashCode, iterator, removeAll, retainAll, toArray, toArray`

    - ### Methods inherited from interface java.util.List

      `addAll, contains, containsAll, remove, removeAll, retainAll, toArray, toArray`

- - ### Field Detail

    - #### DEFAULT_CAPACITY

          public final int DEFAULT_CAPACITY

      See Also:
        Constant Field Values

    - #### DEFAULT_GROWTH

          public final int DEFAULT_GROWTH

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### BlockingArrayQueue

          public BlockingArrayQueue()

      Create a growing partially blocking Queue

    - #### BlockingArrayQueue

          public BlockingArrayQueue(int limit)

      Create a fixed size partially blocking Queue
      Parameters:
        `limit` - The initial capacity and the limit.

    - #### BlockingArrayQueue

          public BlockingArrayQueue(int capacity,
                            int growBy)

      Create a growing partially blocking Queue.
      Parameters:
        `capacity` - Initial capacity
        `growBy` - Incremental capacity.

    - #### BlockingArrayQueue

          public BlockingArrayQueue(int capacity,
                            int growBy,
                            int limit)

      Create a growing limited partially blocking Queue.
      Parameters:
        `capacity` - Initial capacity
        `growBy` - Incremental capacity.
        `limit` - maximum capacity.

  - ### Method Detail

    - #### getCapacity

          public int getCapacity()

    - #### getLimit

          public int getLimit()

    - #### add

          public boolean add(E e)

      Specified by:
        `add` in interface `java.util.Collection<E>`
      Specified by:
        `add` in interface `java.util.concurrent.BlockingQueue<E>`
      Specified by:
        `add` in interface `java.util.List<E>`
      Specified by:
        `add` in interface `java.util.Queue<E>`
      Overrides:
        `add` in class `java.util.AbstractList<E>`

    - #### element

          public E element()

      Specified by:
        `element` in interface `java.util.Queue<E>`

    - #### peek

          public E peek()

      Specified by:
        `peek` in interface `java.util.Queue<E>`

    - #### offer

          public boolean offer(E e)

      Specified by:
        `offer` in interface `java.util.concurrent.BlockingQueue<E>`
      Specified by:
        `offer` in interface `java.util.Queue<E>`

    - #### poll

          public E poll()

      Specified by:
        `poll` in interface `java.util.Queue<E>`

    - #### take

          public E take()
                 throws java.lang.InterruptedException

      Retrieves and removes the head of this queue, waiting if no elements are present on this queue.
      Specified by:
        `take` in interface `java.util.concurrent.BlockingQueue<E>`
      Returns:
        the head of this queue
      Throws:
        `java.lang.InterruptedException` - if interrupted while waiting.

    - #### poll

          public E poll(long time,
               java.util.concurrent.TimeUnit unit)
                 throws java.lang.InterruptedException

      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.
      Specified by:
        `poll` in interface `java.util.concurrent.BlockingQueue<E>`
      Parameters:
        `time` - 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 queue, or `null` if the specified waiting time elapses before an element is present.
      Throws:
        `java.lang.InterruptedException` - if interrupted while waiting.

    - #### remove

          public E remove()

      Specified by:
        `remove` in interface `java.util.Queue<E>`

    - #### clear

          public void clear()

      Specified by:
        `clear` in interface `java.util.Collection<E>`
      Specified by:
        `clear` in interface `java.util.List<E>`
      Overrides:
        `clear` in class `java.util.AbstractList<E>`

    - #### isEmpty

          public boolean isEmpty()

      Specified by:
        `isEmpty` in interface `java.util.Collection<E>`
      Specified by:
        `isEmpty` in interface `java.util.List<E>`
      Overrides:
        `isEmpty` in class `java.util.AbstractCollection<E>`

    - #### size

          public int size()

      Specified by:
        `size` in interface `java.util.Collection<E>`
      Specified by:
        `size` in interface `java.util.List<E>`
      Specified by:
        `size` in class `java.util.AbstractCollection<E>`

    - #### get

          public E get(int index)

      Specified by:
        `get` in interface `java.util.List<E>`
      Specified by:
        `get` in class `java.util.AbstractList<E>`

    - #### remove

          public E remove(int index)

      Specified by:
        `remove` in interface `java.util.List<E>`
      Overrides:
        `remove` in class `java.util.AbstractList<E>`

    - #### set

          public E set(int index,
              E e)

      Specified by:
        `set` in interface `java.util.List<E>`
      Overrides:
        `set` in class `java.util.AbstractList<E>`

    - #### add

          public void add(int index,
                 E e)

      Specified by:
        `add` in interface `java.util.List<E>`
      Overrides:
        `add` in class `java.util.AbstractList<E>`

    - #### drainTo

          public int drainTo(java.util.Collection<? super E> c)

      Specified by:
        `drainTo` in interface `java.util.concurrent.BlockingQueue<E>`

    - #### drainTo

          public int drainTo(java.util.Collection<? super E> c,
                    int maxElements)

      Specified by:
        `drainTo` in interface `java.util.concurrent.BlockingQueue<E>`

    - #### offer

          public boolean offer(E o,
                      long timeout,
                      java.util.concurrent.TimeUnit unit)
                        throws java.lang.InterruptedException

      Specified by:
        `offer` in interface `java.util.concurrent.BlockingQueue<E>`
      Throws:
        `java.lang.InterruptedException`

    - #### put

          public void put(E o)
                   throws java.lang.InterruptedException

      Specified by:
        `put` in interface `java.util.concurrent.BlockingQueue<E>`
      Throws:
        `java.lang.InterruptedException`

    - #### remainingCapacity

          public int remainingCapacity()

      Specified by:
        `remainingCapacity` in interface `java.util.concurrent.BlockingQueue<E>`

Copyright © 2013 FuseSource, Corp.. All Rights Reserved.