Package ghidra.util.timer
Class Watchdog
- java.lang.Object
-
- ghidra.util.timer.Watchdog
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public class Watchdog extends java.lang.Object implements java.io.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, java.lang.Runnable timeoutMethod)
Creates a watchdog (initially disarmed) that will poll for expiration every defaultTimeoutMS milliseconds, callingtimeoutMethod
when triggered.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
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
isEnabled()
Returns the status of the watchdog.
-
-
-
Constructor Detail
-
Watchdog
public Watchdog(long defaultTimeoutMS, java.lang.Runnable timeoutMethod)
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 Detail
-
finalize
public void finalize()
- Overrides:
finalize
in classjava.lang.Object
-
close
public void close()
Releases the background timer that this watchdog uses.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.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 atdefaultWatchdogTimeoutMS
milliseconds in the future thetimeoutMethod
will be called.
-
disarm
public void disarm()
Disables this watchdog.
-
-