java.lang.Object
swim.system.agent.AgentTimer
- All Implemented Interfaces:
Runnable,Timer,TimerContext,TimerFunction,TimerRef
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final AgentNodeprotected final TimerFunctionprotected TimerContext -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancancel()Cancels the timer to prevent it from executing.booleanReturnstrueif the timer is currently scheduled to execute.voidreschedule(long millis) Schedules the timer to execute aftermillismilliseconds has elapsed.voidrun()voidrunTimer()Executes scheduled logic when thisTimerfires.schedule()Returns theScheduleto which the timer is bound.voidsetTimerContext(TimerContext timerContext) Sets the context used to manage thisTimer.Returns the context used to manage thisTimer.voidLifecycle callback invoked after thisTimeris explicitly cancelled.voidtimerWillSchedule(long millis) Lifecycle callback invoked before thisTimeris scheduled for execution.
-
Field Details
-
node
-
timer
-
timerContext
-
-
Constructor Details
-
AgentTimer
-
-
Method Details
-
timerContext
Description copied from interface:TimerReturns the context used to manage thisTimer. Returnsnullif thisTimeris not bound to aSchedule.- Specified by:
timerContextin interfaceTimer
-
setTimerContext
Description copied from interface:TimerSets the context used to manage thisTimer. ATimerContextis assigned when binding thisTimerto aSchedule.- Specified by:
setTimerContextin interfaceTimer
-
runTimer
public void runTimer()Description copied from interface:TimerExecutes scheduled logic when thisTimerfires.- Specified by:
runTimerin interfaceTimer- Specified by:
runTimerin interfaceTimerFunction
-
timerWillSchedule
public void timerWillSchedule(long millis) Description copied from interface:TimerLifecycle callback invoked before thisTimeris scheduled for execution.- Specified by:
timerWillSchedulein interfaceTimer
-
timerDidCancel
public void timerDidCancel()Description copied from interface:TimerLifecycle callback invoked after thisTimeris explicitly cancelled.- Specified by:
timerDidCancelin interfaceTimer
-
schedule
Description copied from interface:TimerContextReturns theScheduleto which the timer is bound.- Specified by:
schedulein interfaceTimerContext
-
isScheduled
public boolean isScheduled()Description copied from interface:TimerContextReturnstrueif the timer is currently scheduled to execute.- Specified by:
isScheduledin interfaceTimerContext- Specified by:
isScheduledin interfaceTimerRef
-
reschedule
public void reschedule(long millis) Description copied from interface:TimerContextSchedules the timer to execute aftermillismilliseconds has elapsed. If the timer is currently scheduled, it will not ececute at its previously scheduled time; it will only execute at the newly scheduled time.- Specified by:
reschedulein interfaceTimerContext- Specified by:
reschedulein interfaceTimerRef
-
cancel
public boolean cancel()Description copied from interface:TimerContextCancels the timer to prevent it from executing. Returnstrueif this operation caused the cancellation of the timer; returnsfalseif the timer was not scheduled to execute.- Specified by:
cancelin interfaceTimerContext- Specified by:
cancelin interfaceTimerRef
-
run
public void run()
-