com.planeth.common.timing
Class Timer

java.lang.Object
  extended bycom.planeth.common.timing.Timer
All Implemented Interfaces:
IThreadControllable, ITimeControllable

public class Timer
extends java.lang.Object
implements IThreadControllable, ITimeControllable

Timer implementation

A Timer is always bound to two main components.
A TimedObjectThread which is the motor of the timer.
A IFunctionPointer which represents the timer task.

The IFunctionPointer is executed once by default.
The number of executions can be defined using the "iterations" flag or it can be set to infinite.

Author:
Andreas Grässer, gal@planet-h.com.
created 04.11.2005
See Also:
TimedObjectThread, WaitTimer, TimerManager

Constructor Summary
Timer(int waitMillis, IFunctionPointer functionPointer)
          Constructor for Timer.
Timer(int waitMillis, IFunctionPointer functionPointer, int iterations)
          Constructor for Timer.
 
Method Summary
 void doNextStep()
          Does the next step
 void interupt()
          Interupts the Timer
 boolean isReadyToDie()
          Returns true, if the IThreadControllable is ready to die
Ready to die means, the Thread which controls the IThreadControllable, will terminate and the IThreadControllable will be deleted.
 void pause(boolean pauseState)
          Pauses/unpauses the timer
 void setReadyToDie()
          Sets the IThreadControllable ready to die.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Timer

public Timer(int waitMillis,
             IFunctionPointer functionPointer)
Constructor for Timer.

Parameters:
waitMillis - the main time to wait until execution of the IFunctionPointer
functionPointer - a pointer interface to the code to be executed

Timer

public Timer(int waitMillis,
             IFunctionPointer functionPointer,
             int iterations)
Constructor for Timer.

Parameters:
waitMillis - the main time to wait until execution of the IFunctionPointer
functionPointer - a pointer interface to the code to be executed
iterations - defines the number of executions (timer iterations) to be done
Method Detail

doNextStep

public void doNextStep()
Description copied from interface: IThreadControllable
Does the next step

Specified by:
doNextStep in interface IThreadControllable
See Also:
IThreadControllable.doNextStep()

isReadyToDie

public boolean isReadyToDie()
Description copied from interface: IThreadControllable
Returns true, if the IThreadControllable is ready to die
Ready to die means, the Thread which controls the IThreadControllable, will terminate and the IThreadControllable will be deleted.

Specified by:
isReadyToDie in interface IThreadControllable
Returns:
Returns true, if the IThreadControllable is ready to die
See Also:
IThreadControllable.isReadyToDie()

setReadyToDie

public void setReadyToDie()
Description copied from interface: IThreadControllable
Sets the IThreadControllable ready to die.

Specified by:
setReadyToDie in interface IThreadControllable
See Also:
IThreadControllable.setReadyToDie()

interupt

public void interupt()
Interupts the Timer


pause

public void pause(boolean pauseState)
Pauses/unpauses the timer

Specified by:
pause in interface ITimeControllable
Parameters:
pauseState -
See Also:
ITimeControllable.pause(boolean)