Class DiscardingBlockingQueue<E>

java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractQueue<E>
java.util.concurrent.ArrayBlockingQueue<E>
org.jmxtrans.embedded.util.concurrent.DiscardingBlockingQueue<E>
All Implemented Interfaces:
Serializable, Iterable<E>, Collection<E>, BlockingQueue<E>, Queue<E>, DiscardingBlockingQueueMBean

public class DiscardingBlockingQueue<E>
extends ArrayBlockingQueue<E>
implements DiscardingBlockingQueueMBean
Automatically discard the oldest element if the queue is full.
Author:
Cyrille Le Clerc
See Also:
Serialized Form
  • Constructor Details

    • DiscardingBlockingQueue

      public DiscardingBlockingQueue​(int capacity)
      Creates a DiscardingBlockingQueue with the given (fixed) capacity and default access policy.
      Parameters:
      capacity - the capacity of this queue
      Throws:
      IllegalArgumentException - if capacity < 1
    • DiscardingBlockingQueue

      public DiscardingBlockingQueue​(int capacity, boolean fair)
      Creates a DiscardingBlockingQueue with the given (fixed) capacity and the specified access policy.
      Parameters:
      capacity - the capacity of this queue
      fair - if true then queue accesses for threads blocked on insertion or removal, are processed in FIFO order; if false the access order is unspecified.
      Throws:
      IllegalArgumentException - if capacity < 1
    • DiscardingBlockingQueue

      public DiscardingBlockingQueue​(int capacity, boolean fair, Collection<? extends E> c)
      Creates an DiscardingBlockingQueue with the given (fixed) capacity, the specified access policy and initially containing the elements of the given collection, added in traversal order of the collection's iterator.
      Parameters:
      capacity - the capacity of this queue
      fair - if true then queue accesses for threads blocked on insertion or removal, are processed in FIFO order; if false the access order is unspecified.
      c - the collection of elements to initially contain
      Throws:
      IllegalArgumentException - if capacity is less than c.size(), or less than 1.
      NullPointerException - if the specified collection or any
  • Method Details