Class LazyPriorityQueueScheduler

  • All Implemented Interfaces:
    QueueScheduler, java.lang.Iterable<Job>, java.util.Collection<Job>, java.util.concurrent.BlockingQueue<Job>, java.util.Queue<Job>

    public class LazyPriorityQueueScheduler
    extends AbstractPriorityQueueScheduler
    This class provides and implementation of scheduler with a priority sensitive queue and polls from iterator when queue is empty.

    Jobs in queue will be processed first in order of higher priority, followed by requests in the iterator.

    Author:
    Maksim Tkachenko, Ween Jiann Lee
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean isEmpty()  
      Job poll()  
      Job poll​(long time, java.util.concurrent.TimeUnit unit)  
      • Methods inherited from class java.util.AbstractQueue

        add, addAll, clear, element, remove
      • Methods inherited from class java.util.AbstractCollection

        contains, containsAll, remove, removeAll, retainAll, toArray, toArray, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.concurrent.BlockingQueue

        add, contains, remove
      • Methods inherited from interface java.util.Collection

        addAll, clear, containsAll, equals, hashCode, parallelStream, removeAll, removeIf, retainAll, spliterator, stream, toArray, toArray, toArray
      • Methods inherited from interface java.lang.Iterable

        forEach
      • Methods inherited from interface java.util.Queue

        element, remove
    • Constructor Detail

      • LazyPriorityQueueScheduler

        public LazyPriorityQueueScheduler​(java.util.Iterator<Request> requests,
                                          Handler handler)
        Constructs an instance of lazy scheduler with a default handler.
        Parameters:
        requests - An iterator to obtain requests
        handler - The default handler to use
      • LazyPriorityQueueScheduler

        public LazyPriorityQueueScheduler​(java.util.Iterator<Request> requests)
        Constructs an instance of lazy scheduler without a default handler.
        Parameters:
        requests - An iterator to obtain requests
    • Method Detail

      • poll

        public final Job poll​(long time,
                              @Nonnull
                              java.util.concurrent.TimeUnit unit)
                       throws java.lang.InterruptedException
        Throws:
        java.lang.InterruptedException
      • poll

        public final Job poll()
      • isEmpty

        public final boolean isEmpty()
        Specified by:
        isEmpty in interface java.util.Collection<Job>
        Overrides:
        isEmpty in class java.util.AbstractCollection<Job>