Package gov.usgs.earthquake.util
Class RoundRobinBlockingQueue<T>
- java.lang.Object
-
- gov.usgs.earthquake.util.RoundRobinQueue<T>
-
- gov.usgs.earthquake.util.RoundRobinBlockingQueue<T>
-
- Type Parameters:
T- queue item type.
- All Implemented Interfaces:
java.lang.Iterable<T>,java.util.Collection<T>,java.util.concurrent.BlockingQueue<T>,java.util.Queue<T>
- Direct Known Subclasses:
ListenerNotificationQueue,NotificationEventBlockingQueue
public class RoundRobinBlockingQueue<T> extends RoundRobinQueue<T> implements java.util.concurrent.BlockingQueue<T>
Round Robin Blocking Queue.put(Object)andtake()are recommended, as other methods internally call these methods.
-
-
Constructor Summary
Constructors Constructor Description RoundRobinBlockingQueue()Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(T e)Add an item to the queue.booleancontains(java.lang.Object e)Check if queue contains an item.intdrainTo(java.util.Collection<? super T> c)Empty queue into a collection.intdrainTo(java.util.Collection<? super T> c, int max)Empty queue into a collection, stopping after max elements.booleanoffer(T e)Offer an item to the queue.booleanoffer(T e, long timeout, java.util.concurrent.TimeUnit unit)Offer an item to the queue.Tpoll(long timeout, java.util.concurrent.TimeUnit unit)Retrieves and removes the head of this queue, waiting up to the specified wait time if necessary for an element to become available.voidput(T e)Put an item in the queue.intremainingCapacity()Unbounded queues return Integer.MAX_VALUE.booleanremove(java.lang.Object e)Remove an object from the queue.Ttake()Remove an object from the queue.-
Methods inherited from class gov.usgs.earthquake.util.RoundRobinQueue
addAll, clear, containsAll, element, getQueueId, isEmpty, iterator, peek, poll, remove, removeAll, retainAll, size, toArray, toArray, toList
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
-
-
Method Detail
-
add
public boolean add(T e)
Add an item to the queue.
-
contains
public boolean contains(java.lang.Object e)
Check if queue contains an item.- Specified by:
containsin interfacejava.util.concurrent.BlockingQueue<T>- Specified by:
containsin interfacejava.util.Collection<T>- Overrides:
containsin classRoundRobinQueue<T>
-
offer
public boolean offer(T e)
Offer an item to the queue. Callsadd(Object), but returns false if any exceptions thrown.- Specified by:
offerin interfacejava.util.concurrent.BlockingQueue<T>- Specified by:
offerin interfacejava.util.Queue<T>- Overrides:
offerin classRoundRobinQueue<T>- Parameters:
e- item to add- Returns:
- true if added, false otherwise.
-
offer
public boolean offer(T e, long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
Offer an item to the queue. Same asoffer(Object), this is an unbounded queue.- Specified by:
offerin interfacejava.util.concurrent.BlockingQueue<T>- Throws:
java.lang.InterruptedException
-
poll
public T poll(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
Retrieves and removes the head of this queue, waiting up to the specified wait time if necessary for an element to become available.- Specified by:
pollin interfacejava.util.concurrent.BlockingQueue<T>- Throws:
java.lang.InterruptedException
-
put
public void put(T e) throws java.lang.InterruptedException
Put an item in the queue.- Specified by:
putin interfacejava.util.concurrent.BlockingQueue<T>- Throws:
java.lang.InterruptedException- if interrupted while acquiring lock.
-
remainingCapacity
public int remainingCapacity()
Unbounded queues return Integer.MAX_VALUE.- Specified by:
remainingCapacityin interfacejava.util.concurrent.BlockingQueue<T>- Returns:
- Integer.MAX_VALUE;
-
remove
public boolean remove(java.lang.Object e)
Remove an object from the queue.- Specified by:
removein interfacejava.util.concurrent.BlockingQueue<T>- Specified by:
removein interfacejava.util.Collection<T>- Overrides:
removein classRoundRobinQueue<T>
-
take
public T take() throws java.lang.InterruptedException
Remove an object from the queue.- Specified by:
takein interfacejava.util.concurrent.BlockingQueue<T>- Throws:
java.lang.InterruptedException
-
drainTo
public int drainTo(java.util.Collection<? super T> c)
Empty queue into a collection.- Specified by:
drainToin interfacejava.util.concurrent.BlockingQueue<T>
-
-