cz.cuni.pogamut.experiments
Class Timer

java.lang.Object
  extended by cz.cuni.pogamut.experiments.Timer

public class Timer
extends java.lang.Object

Timer used for scheduling events in experiments. Execution of this timer could be paused. Some of this code was copied from java.util.Timer;


Nested Class Summary
(package private)  class Timer.TimerThread
           
 
Field Summary
protected  Timer.TimerThread executionThread
           
protected  java.util.PriorityQueue<TimerTask> queue
          Queue of tasks.
private  java.lang.Object threadReaper
          This object causes the timer's task execution thread to exit gracefully when there are no live references to the Timer object and no tasks in the timer queue.
protected  TimeProvider timeProvider
           
 
Constructor Summary
Timer(Experiment experiment)
          Creates a new instance of Timer and starts it.
 
Method Summary
 void schedule(TimerTask task, long delay)
          Schedules task for execution.
 void stopTimer()
          Stops timer thread, no other tasks can be scheduled after calling this method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

queue

protected final java.util.PriorityQueue<TimerTask> queue
Queue of tasks.


threadReaper

private java.lang.Object threadReaper
This object causes the timer's task execution thread to exit gracefully when there are no live references to the Timer object and no tasks in the timer queue. It is used in preference to a finalizer on Timer as such a finalizer would be susceptible to a subclass's finalizer forgetting to call it.


executionThread

protected Timer.TimerThread executionThread

timeProvider

protected TimeProvider timeProvider
Constructor Detail

Timer

public Timer(Experiment experiment)
Creates a new instance of Timer and starts it.

Method Detail

schedule

public void schedule(TimerTask task,
                     long delay)
Schedules task for execution.


stopTimer

public void stopTimer()
Stops timer thread, no other tasks can be scheduled after calling this method.