edu.iu.iv.common
Class QueueScheduler

java.lang.Object
  |
  +--edu.iu.iv.common.QueueScheduler
All Implemented Interfaces:
Scheduler

public class QueueScheduler
extends java.lang.Object
implements Scheduler

A basic queue-based scheduler. When algorithms are in the queue, they are run one at a time by a separate thread, which is killed once the queue is emptied. runNow() and schedule() place algorithms at the front and back of the queue, respectively. This means that runNow() will not necessarily start an algorithm immediately - if another algorithm is already running, the scheduler thread will wait until that one is finished before running the new one.

Author:
Josh Bonner

Constructor Summary
QueueScheduler()
           
 
Method Summary
 void runNow(Algorithm algorithm)
          Schedules an algorithm to be run immediately.
 void schedule(Algorithm algorithm)
          Schedules the given algorithm to be run at a later time.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QueueScheduler

public QueueScheduler()
Method Detail

runNow

public void runNow(Algorithm algorithm)
Description copied from interface: Scheduler
Schedules an algorithm to be run immediately.

Specified by:
runNow in interface Scheduler
Parameters:
algorithm - the algorithm to run
See Also:
Scheduler.runNow(edu.iu.iv.core.Algorithm)

schedule

public void schedule(Algorithm algorithm)
Description copied from interface: Scheduler
Schedules the given algorithm to be run at a later time. The actual scheduling order is implementation-defined.

Specified by:
schedule in interface Scheduler
Parameters:
algorithm - the algorithm to be scheduled
See Also:
Scheduler.schedule(edu.iu.iv.core.Algorithm)