Class Watchdog

java.lang.Object
ghidra.util.timer.Watchdog
All Implemented Interfaces:
Closeable, AutoCloseable

public class Watchdog extends Object implements Closeable
A reusable watchdog that will execute a callback if the watchdog is not disarmed before it expires.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Watchdog(long defaultTimeoutMS, Runnable timeoutMethod)
    Creates a watchdog (initially disarmed) that will poll for expiration every defaultTimeoutMS milliseconds, calling timeoutMethod when triggered.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    arm()
    Enables this watchdog so that at defaultWatchdogTimeoutMS milliseconds in the future the timeoutMethod will be called.
    void
    Releases the background timer that this watchdog uses.
    void
    Disables this watchdog.
    void
     
    boolean
    Returns the status of the watchdog.

    Methods inherited from class java.lang.Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Watchdog

      public Watchdog(long defaultTimeoutMS, Runnable timeoutMethod)
      Creates a watchdog (initially disarmed) that will poll for expiration every defaultTimeoutMS milliseconds, calling timeoutMethod when triggered.

      Parameters:
      defaultTimeoutMS - number of milliseconds that the watchdog will wait after being armed before calling the timeout method.
      timeoutMethod - Runnable functional callback.
  • Method Details

    • finalize

      public void finalize()
      Overrides:
      finalize in class Object
    • close

      public void close()
      Releases the background timer that this watchdog uses.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
    • isEnabled

      public boolean isEnabled()
      Returns the status of the watchdog.
      Returns:
      true if the watchdog is armed, false if the watchdog is disarmed
    • arm

      public void arm()
      Enables this watchdog so that at defaultWatchdogTimeoutMS milliseconds in the future the timeoutMethod will be called.
    • disarm

      public void disarm()
      Disables this watchdog.