Module swim.system

Class AgentTimer

java.lang.Object
swim.system.agent.AgentTimer
All Implemented Interfaces:
Runnable, Timer, TimerContext, TimerFunction, TimerRef

public class AgentTimer extends Object implements Timer, TimerContext, TimerRef, Runnable
  • Field Details

  • Constructor Details

  • Method Details

    • timerContext

      public TimerContext timerContext()
      Description copied from interface: Timer
      Returns the context used to manage this Timer. Returns null if this Timer is not bound to a Schedule.
      Specified by:
      timerContext in interface Timer
    • setTimerContext

      public void setTimerContext(TimerContext timerContext)
      Description copied from interface: Timer
      Sets the context used to manage this Timer. A TimerContext is assigned when binding this Timer to a Schedule.
      Specified by:
      setTimerContext in interface Timer
    • runTimer

      public void runTimer()
      Description copied from interface: Timer
      Executes scheduled logic when this Timer fires.
      Specified by:
      runTimer in interface Timer
      Specified by:
      runTimer in interface TimerFunction
    • timerWillSchedule

      public void timerWillSchedule(long millis)
      Description copied from interface: Timer
      Lifecycle callback invoked before this Timer is scheduled for execution.
      Specified by:
      timerWillSchedule in interface Timer
    • timerDidCancel

      public void timerDidCancel()
      Description copied from interface: Timer
      Lifecycle callback invoked after this Timer is explicitly cancelled.
      Specified by:
      timerDidCancel in interface Timer
    • schedule

      public Schedule schedule()
      Description copied from interface: TimerContext
      Returns the Schedule to which the timer is bound.
      Specified by:
      schedule in interface TimerContext
    • isScheduled

      public boolean isScheduled()
      Description copied from interface: TimerContext
      Returns true if the timer is currently scheduled to execute.
      Specified by:
      isScheduled in interface TimerContext
      Specified by:
      isScheduled in interface TimerRef
    • reschedule

      public void reschedule(long millis)
      Description copied from interface: TimerContext
      Schedules the timer to execute after millis 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 interface TimerContext
      Specified by:
      reschedule in interface TimerRef
    • cancel

      public boolean cancel()
      Description copied from interface: TimerContext
      Cancels the timer to prevent it from executing. Returns true if this operation caused the cancellation of the timer; returns false if the timer was not scheduled to execute.
      Specified by:
      cancel in interface TimerContext
      Specified by:
      cancel in interface TimerRef
    • run

      public void run()
      Specified by:
      run in interface Runnable