Interface Timer

All Superinterfaces:
TimerFunction
All Known Implementing Classes:
AbstractTimer, AgentTimer

public interface Timer extends TimerFunction
Stateful TimerFunction to invoke at a scheduled time, with lifecycle callbacks, and a TimerContext for self-management. Use Schedule.setTimer(long, TimerFunction) to schedule a new Timer for execution.
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Executes scheduled logic when this Timer fires.
    void
    Sets the context used to manage this Timer.
    Returns the context used to manage this Timer.
    void
    Lifecycle callback invoked after this Timer is explicitly cancelled.
    void
    timerWillSchedule(long millis)
    Lifecycle callback invoked before this Timer is scheduled for execution.
  • Method Details

    • timerContext

      TimerContext timerContext()
      Returns the context used to manage this Timer. Returns null if this Timer is not bound to a Schedule.
    • setTimerContext

      void setTimerContext(TimerContext timerContext)
      Sets the context used to manage this Timer. A TimerContext is assigned when binding this Timer to a Schedule.
    • runTimer

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

      void timerWillSchedule(long millis)
      Lifecycle callback invoked before this Timer is scheduled for execution.
    • timerDidCancel

      void timerDidCancel()
      Lifecycle callback invoked after this Timer is explicitly cancelled.