org.eu.mayrhofer.authentication
Class SafetyBeltTimer

java.lang.Object
  extended by org.eu.mayrhofer.authentication.SafetyBeltTimer
All Implemented Interfaces:
java.lang.Runnable

public class SafetyBeltTimer
extends java.lang.Object
implements java.lang.Runnable

This is a currently safety belt against the dongle being stuck in authentication mode or the other dongle never entering authentication mode. I.e., it is a safeguard against that specific loop ending up being an endless loop (which is not good in terms of fault tolerance). This helper class implements a "grenade timer" that will let the main event loop bail out with a timeout when it is stuck for too long at the same round number. It is also useful for other purposes, even if it has been created specifically for DongleProtocolHandler#handleDongleCommunication for safeguarding its main loop. There is no need to explicitly stop the thread, it will just time out and stop.

Version:
1.0
Author:
Rene Mayrhofer

Constructor Summary
SafetyBeltTimer(int time)
           
 
Method Summary
 boolean isTriggered()
          Returns true when the timer has triggered and the task should terminate.
 void reset()
          Allows to send a hearbeat signal to the timer by resetting it.
 void run()
          Implements the timer background thread.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SafetyBeltTimer

public SafetyBeltTimer(int time)
Parameters:
time - The time, in milliseconds, that this timer will use.
Method Detail

run

public void run()
Implements the timer background thread.

Specified by:
run in interface java.lang.Runnable

isTriggered

public boolean isTriggered()
Returns true when the timer has triggered and the task should terminate.


reset

public void reset()
Allows to send a hearbeat signal to the timer by resetting it. This allows to implement heartbeat like functionality where the timer can get reset whenever some progress is being made.



2005-2006, Rene Mayrhofer.