Package io.deephaven.modelfarm.util
Class KeyedPriorityBlockingQueue<E>
java.lang.Object
io.deephaven.modelfarm.util.KeyedPriorityBlockingQueue<E>
A priority blocking queue that maintains one element per key. If a later request comes in of higher priority, the
lower priority item is replaced by the higher priority item.
The element type must be usable in a hash map.
-
Constructor Summary
-
Method Summary
-
Constructor Details
-
KeyedPriorityBlockingQueue
public KeyedPriorityBlockingQueue()
-
-
Method Details
-
enqueue
Add an element to the queue. If the element is already in the queue, the element's priority will be the higher of the existing element and the new element.- Parameters:
element
- element to enqueue.priority
- priority of the element.- Returns:
true
if theelement
was newly inserted to the queue or reinserted with a higher priority, otherwisefalse
.
-
take
Retrieves and removes the head of this queue, waiting if necessary until an element becomes available.- Returns:
- the head of this queue
- Throws:
InterruptedException
- if interrupted while waiting
-
isEmpty
public boolean isEmpty()Returns true if the queue is empty; false otherwise.- Returns:
- true if the queue is empty; false otherwise.
-