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:
Iterable<T>,Collection<T>,BlockingQueue<T>,Queue<T>
- Direct Known Subclasses:
ListenerNotificationQueue,NotificationEventBlockingQueue
Round Robin Blocking Queue.
put(Object) and take() are recommended, as other methods
internally call these methods.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanAdd an item to the queue.booleanCheck if queue contains an item.intdrainTo(Collection<? super T> c) Empty queue into a collection.intdrainTo(Collection<? super T> c, int max) Empty queue into a collection, stopping after max elements.booleanOffer an item to the queue.booleanOffer an item to the queue.Retrieves and removes the head of this queue, waiting up to the specified wait time if necessary for an element to become available.voidPut an item in the queue.intUnbounded queues return Integer.MAX_VALUE.booleanRemove an object from the queue.take()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, toListMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Collection
addAll, clear, containsAll, equals, hashCode, isEmpty, iterator, parallelStream, removeAll, removeIf, retainAll, size, spliterator, stream, toArray, toArray, toArray
-
Constructor Details
-
RoundRobinBlockingQueue
public RoundRobinBlockingQueue()Constructor
-
-
Method Details
-
add
Add an item to the queue.- Specified by:
addin interfaceBlockingQueue<T>- Specified by:
addin interfaceCollection<T>- Specified by:
addin interfaceQueue<T>- Overrides:
addin classRoundRobinQueue<T>- Parameters:
e- item to add- Returns:
- true if added.
-
contains
Check if queue contains an item.- Specified by:
containsin interfaceBlockingQueue<T>- Specified by:
containsin interfaceCollection<T>- Overrides:
containsin classRoundRobinQueue<T>
-
offer
Offer an item to the queue. Callsadd(Object), but returns false if any exceptions thrown.- Specified by:
offerin interfaceBlockingQueue<T>- Specified by:
offerin interfaceQueue<T>- Overrides:
offerin classRoundRobinQueue<T>- Parameters:
e- item to add- Returns:
- true if added, false otherwise.
-
offer
Offer an item to the queue. Same asoffer(Object), this is an unbounded queue.- Specified by:
offerin interfaceBlockingQueue<T>- Throws:
InterruptedException
-
poll
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 interfaceBlockingQueue<T>- Throws:
InterruptedException
-
put
Put an item in the queue.- Specified by:
putin interfaceBlockingQueue<T>- Throws:
InterruptedException- if interrupted while acquiring lock.
-
remainingCapacity
public int remainingCapacity()Unbounded queues return Integer.MAX_VALUE.- Specified by:
remainingCapacityin interfaceBlockingQueue<T>- Returns:
- Integer.MAX_VALUE;
-
remove
Remove an object from the queue.- Specified by:
removein interfaceBlockingQueue<T>- Specified by:
removein interfaceCollection<T>- Overrides:
removein classRoundRobinQueue<T>
-
take
Remove an object from the queue.- Specified by:
takein interfaceBlockingQueue<T>- Throws:
InterruptedException
-
drainTo
Empty queue into a collection.- Specified by:
drainToin interfaceBlockingQueue<T>
-
drainTo
Empty queue into a collection, stopping after max elements.- Specified by:
drainToin interfaceBlockingQueue<T>
-