Interface TimerContext

All Superinterfaces:
TimerRef
All Known Implementing Classes:
AgentTimer

public interface TimerContext extends TimerRef
Internal context that binds a Timer to a Schedule. A TimerContext can be used by a Timer to check its status, to reschedule itself, and to cancel itself. TimerContext is thread safe.
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Cancels the timer to prevent it from executing.
    boolean
    Returns true if the timer is currently scheduled to execute.
    void
    reschedule(long millis)
    Schedules the timer to execute after millis milliseconds has elapsed.
    Returns the Schedule to which the timer is bound.
  • Method Details

    • schedule

      Schedule schedule()
      Returns the Schedule to which the timer is bound.
    • isScheduled

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

      void reschedule(long millis)
      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 TimerRef
      Throws:
      TimerException - if millis is negative.
    • cancel

      boolean cancel()
      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 TimerRef