java.lang.Object
swim.system.agent.AgentTimer
- All Implemented Interfaces:
Runnable
,Timer
,TimerContext
,TimerFunction
,TimerRef
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final AgentNode
protected final TimerFunction
protected TimerContext
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
cancel()
Cancels the timer to prevent it from executing.boolean
Returnstrue
if the timer is currently scheduled to execute.void
reschedule
(long millis) Schedules the timer to execute aftermillis
milliseconds has elapsed.void
run()
void
runTimer()
Executes scheduled logic when thisTimer
fires.schedule()
Returns theSchedule
to which the timer is bound.void
setTimerContext
(TimerContext timerContext) Sets the context used to manage thisTimer
.Returns the context used to manage thisTimer
.void
Lifecycle callback invoked after thisTimer
is explicitly cancelled.void
timerWillSchedule
(long millis) Lifecycle callback invoked before thisTimer
is scheduled for execution.
-
Field Details
-
node
-
timer
-
timerContext
-
-
Constructor Details
-
AgentTimer
-
-
Method Details
-
timerContext
Description copied from interface:Timer
Returns the context used to manage thisTimer
. Returnsnull
if thisTimer
is not bound to aSchedule
.- Specified by:
timerContext
in interfaceTimer
-
setTimerContext
Description copied from interface:Timer
Sets the context used to manage thisTimer
. ATimerContext
is assigned when binding thisTimer
to aSchedule
.- Specified by:
setTimerContext
in interfaceTimer
-
runTimer
public void runTimer()Description copied from interface:Timer
Executes scheduled logic when thisTimer
fires.- Specified by:
runTimer
in interfaceTimer
- Specified by:
runTimer
in interfaceTimerFunction
-
timerWillSchedule
public void timerWillSchedule(long millis) Description copied from interface:Timer
Lifecycle callback invoked before thisTimer
is scheduled for execution.- Specified by:
timerWillSchedule
in interfaceTimer
-
timerDidCancel
public void timerDidCancel()Description copied from interface:Timer
Lifecycle callback invoked after thisTimer
is explicitly cancelled.- Specified by:
timerDidCancel
in interfaceTimer
-
schedule
Description copied from interface:TimerContext
Returns theSchedule
to which the timer is bound.- Specified by:
schedule
in interfaceTimerContext
-
isScheduled
public boolean isScheduled()Description copied from interface:TimerContext
Returnstrue
if the timer is currently scheduled to execute.- Specified by:
isScheduled
in interfaceTimerContext
- Specified by:
isScheduled
in interfaceTimerRef
-
reschedule
public void reschedule(long millis) Description copied from interface:TimerContext
Schedules the timer to execute aftermillis
milliseconds 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:
reschedule
in interfaceTimerContext
- Specified by:
reschedule
in interfaceTimerRef
-
cancel
public boolean cancel()Description copied from interface:TimerContext
Cancels the timer to prevent it from executing. Returnstrue
if this operation caused the cancellation of the timer; returnsfalse
if the timer was not scheduled to execute.- Specified by:
cancel
in interfaceTimerContext
- Specified by:
cancel
in interfaceTimerRef
-
run
public void run()
-