|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.amx.duet.util.Timer
com.amx.duet.tools.util.WaitTimer
The WaitTimer class extends the Timer class, which provides API's for creating single value timeouts.
The WaitTimer
uses a standard listener model interface, TimerListener
.
A WaitTimer is created by supplying a TimerListener
object, a timeout value in milliseconds and
optional repeat value and argument object. Once a WaitTimer is created an ID is automatically assigned
to it. WaitTimer are NOT started at construction. The timer commences upon the call to start().
Upon timeout, the TimerListener
's handleTimerEvent() is called with the Timer
object associated with the timeout passed as a parameter.
WaitTimer are cancelled by calling the cancel() method.
The main difference between the Timer and the WaitTimer classes is that the WaitTimer keeps track of its started
state. A call to isStarted()
will verify if the timer has been started or not.
Internally, timers are implemented using a single thread. Because of this, processing within the
TimerListener
handleTimerEvent() should be kept to a minimum as this can affect the
accuracy of other timer's in the system.
Field Summary |
Fields inherited from class com.amx.duet.util.Timer |
INFINITE, INVALID |
Constructor Summary | |
WaitTimer(com.amx.duet.util.TimerListener listener,
long timeout)
Constructs a one-time, non-repeating timer. |
|
WaitTimer(com.amx.duet.util.TimerListener listener,
long timeout,
int repeat,
java.lang.Object argument)
Constructs a repeatable timer with an optional Object argument. |
Method Summary | |
void |
cancel()
Cancels a timer. |
int |
getTimerID()
Retrieve's the internal ID value assigned to this timer. |
boolean |
isStarted()
Retrieve's the timer's internal started state. |
boolean |
start()
Starts a timer. |
Methods inherited from class com.amx.duet.util.Timer |
getArgument, setArgument, setTimeout |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public WaitTimer(com.amx.duet.util.TimerListener listener, long timeout)
listener
- a TimerListener object that will handle timeout eventstimeout
- length of timeout in millisecondspublic WaitTimer(com.amx.duet.util.TimerListener listener, long timeout, int repeat, java.lang.Object argument)
listener
- a TimerListener object that will handle timer eventstimeout
- length of timeout in millisecondsrepeat
- number of times the timer should repeat. 0 indicates no repeat, Timer.INFINITE
indicates the Timer should repeat until cancelled. For example, a repeat value of 1 will cause the
timer to trigger twice.argument
- an Object instance that is retained by the Timer object.Method Detail |
public int getTimerID()
public void cancel()
public boolean start()
public boolean isStarted()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |