-
- All Superinterfaces:
TimerFunction
- All Known Implementing Classes:
AbstractTimer
,AgentTimer
public interface Timer extends TimerFunction
StatefulTimerFunction
to invoke at a scheduled time, with lifecycle callbacks, and aTimerContext
for self-management. UseSchedule.setTimer(long, TimerFunction)
to schedule a newTimer
for execution.- See Also:
AbstractTimer
,Schedule
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
runTimer()
Executes scheduled logic when thisTimer
fires.void
setTimerContext(TimerContext timerContext)
Sets the context used to manage thisTimer
.TimerContext
timerContext()
Returns the context used to manage thisTimer
.void
timerDidCancel()
Lifecycle callback invoked after thisTimer
is explicitly cancelled.void
timerWillSchedule(long millis)
Lifecycle callback invoked before thisTimer
is scheduled for execution.
-
-
-
Method Detail
-
timerContext
TimerContext timerContext()
Returns the context used to manage thisTimer
. Returnsnull
if thisTimer
is not bound to aSchedule
.
-
setTimerContext
void setTimerContext(TimerContext timerContext)
Sets the context used to manage thisTimer
. ATimerContext
is assigned when binding thisTimer
to aSchedule
.
-
runTimer
void runTimer()
Executes scheduled logic when thisTimer
fires.- Specified by:
runTimer
in interfaceTimerFunction
-
timerWillSchedule
void timerWillSchedule(long millis)
Lifecycle callback invoked before thisTimer
is scheduled for execution.
-
timerDidCancel
void timerDidCancel()
Lifecycle callback invoked after thisTimer
is explicitly cancelled.
-
-