Package ghidra.util.timer
Class Watchdog
java.lang.Object
ghidra.util.timer.Watchdog
- All Implemented Interfaces:
Closeable
,AutoCloseable
A reusable watchdog that will execute a callback if the watchdog is not disarmed before
it expires.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
arm()
Enables this watchdog so that atdefaultWatchdogTimeoutMS
milliseconds in the future thetimeoutMethod
will be called.void
close()
Releases the background timer that this watchdog uses.void
disarm()
Disables this watchdog.void
finalize()
boolean
Returns the status of the watchdog.
-
Constructor Details
-
Watchdog
Creates a watchdog (initially disarmed) that will poll for expiration every defaultTimeoutMS milliseconds, callingtimeoutMethod
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() -
close
public void close()Releases the background timer that this watchdog uses.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
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 atdefaultWatchdogTimeoutMS
milliseconds in the future thetimeoutMethod
will be called. -
disarm
public void disarm()Disables this watchdog.
-