jAER project on SourceForge

net.sf.jaer.eventprocessing
Class TimeLimiter

java.lang.Object
  extended by java.util.Timer
      extended by net.sf.jaer.eventprocessing.TimeLimiter

public final class TimeLimiter
extends java.util.Timer

This utility class allows setting a limiting time and cheap checking for whether this time is exceeded. Event processors use it to limit their own execution time. The caller initializes the TimeLimiter and then calls to see if this time has been exceeded.

Author:
tobi

Field Summary
 boolean timedOut
           
 
Constructor Summary
TimeLimiter()
          Creates a new time limiter with timeout ms.
 
Method Summary
 int getTimeLimitMs()
           
 boolean isEnabled()
           
 boolean isTimedOut()
          check if timer expired
 void restart()
           
 void setEnabled(boolean enabled)
          Set true to enable time timeouts, false to disable starting timer
 void setTimeLimitMs(int timeLimitMs)
           
 
Methods inherited from class java.util.Timer
cancel, purge, schedule, schedule, schedule, schedule, scheduleAtFixedRate, scheduleAtFixedRate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

timedOut

public volatile boolean timedOut
Constructor Detail

TimeLimiter

public TimeLimiter()
Creates a new time limiter with timeout ms. Doesn't start it.

Method Detail

restart

public final void restart()

isTimedOut

public final boolean isTimedOut()
check if timer expired

Returns:
true if time exceeded and timeout is enabled, otherwise false

getTimeLimitMs

public final int getTimeLimitMs()

setTimeLimitMs

public final void setTimeLimitMs(int timeLimitMs)

isEnabled

public final boolean isEnabled()

setEnabled

public final void setEnabled(boolean enabled)
Set true to enable time timeouts, false to disable starting timer


jAER project on SourceForge