Class KeyedPriorityBlockingQueue<E>

java.lang.Object
io.deephaven.modelfarm.util.KeyedPriorityBlockingQueue<E>

public class KeyedPriorityBlockingQueue<E> extends Object
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 Details

    • KeyedPriorityBlockingQueue

      public KeyedPriorityBlockingQueue()
  • Method Details

    • enqueue

      public boolean enqueue(E element, int priority)
      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 the element was newly inserted to the queue or reinserted with a higher priority, otherwise false.
    • take

      public E take() throws InterruptedException
      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.