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.CloseableA 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, callingtimeoutMethodwhen triggered.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidarm()Enables this watchdog so that atdefaultWatchdogTimeoutMSmilliseconds in the future thetimeoutMethodwill be called.voidclose()Releases the background timer that this watchdog uses.voiddisarm()Disables this watchdog.voidfinalize()booleanisEnabled()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, callingtimeoutMethodwhen triggered.- Parameters:
defaultTimeoutMS- number of milliseconds that the watchdog will wait after being armed before calling the timeout method.timeoutMethod-Runnablefunctional callback.
-
-
Method Detail
-
finalize
public void finalize()
- Overrides:
finalizein classjava.lang.Object
-
close
public void close()
Releases the background timer that this watchdog uses.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein 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 atdefaultWatchdogTimeoutMSmilliseconds in the future thetimeoutMethodwill be called.
-
disarm
public void disarm()
Disables this watchdog.
-
-