Class TimeoutTimer

java.lang.Object
com.iizigo.swt.TimeoutTimer

public class TimeoutTimer extends Object
Class that handles a timeout timer that can be started, retriggered, stopped.

The runnable runs once, in the SWT thread, timeout milliseconds after the LAST call of retrigger(): a burst of calls is one run. A schedule that expires after a later call moved the expected time on waits for the remainder; one that expires late, the SWT thread having been busy, runs at once. A call after the run starts the timer again. (CC-FIX-DESIGNER-MARKERS, MP-D-1: the timer never armed - its guard returned while the last-retrigger time was still 0, and nothing else set it - and an armed one never called InvokeSWTLater.trigger(), so its runnable never ran.)

Author:
Christopher Mindus
  • Constructor Details

    • TimeoutTimer

      public TimeoutTimer(long timeout, Runnable runnable)
      Creates a timeout timer that will fire in the timeout.
      Parameters:
      timeout - The timeout in milliseconds.
      runnable - The runnable to call at timeout.
  • Method Details

    • stop

      public void stop()
      Stops the timer.
    • retrigger

      public void retrigger()
      Starts or re-triggers the timer to the initial timeout: the runnable runs timeout milliseconds after the last call.
    • isScheduled

      public boolean isScheduled()
      Checks if the timer is scheduled.
      Returns:
      true if it will fire event within the timeout.