mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-06 03:50:02 +02:00
GP-443 - Tasks - Fixed potential unnecessary forced wait when using the
TaskLauncher
This commit is contained in:
parent
4300bec382
commit
d85e2c1c71
12 changed files with 306 additions and 306 deletions
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,14 +15,14 @@
|
|||
*/
|
||||
package ghidra.util.timer;
|
||||
|
||||
import ghidra.util.Msg;
|
||||
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import ghidra.util.Msg;
|
||||
|
||||
public class GTimer {
|
||||
private static Timer timer;
|
||||
private static GTimerMonitor DO_NOTHING_MONITOR = new DoNothingMonitor();
|
||||
private static GTimerMonitor DO_NOTHING_MONITOR = GTimerMonitor.DUMMY;
|
||||
|
||||
/**
|
||||
* Schedules a runnable for execution after the specified delay.
|
||||
|
@ -48,7 +47,8 @@ public class GTimer {
|
|||
* @param callback the runnable to be executed.
|
||||
* @return a GTimerMonitor which allows the caller to cancel the timer and check its status.
|
||||
*/
|
||||
public static GTimerMonitor scheduleRepeatingRunnable(long delay, long period, Runnable callback) {
|
||||
public static GTimerMonitor scheduleRepeatingRunnable(long delay, long period,
|
||||
Runnable callback) {
|
||||
GTimerTask gTimerTask = new GTimerTask(callback);
|
||||
getTimer().schedule(gTimerTask, delay, period);
|
||||
return gTimerTask;
|
||||
|
@ -61,24 +61,6 @@ public class GTimer {
|
|||
return timer;
|
||||
}
|
||||
|
||||
static class DoNothingMonitor implements GTimerMonitor {
|
||||
@Override
|
||||
public boolean cancel() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean didRun() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wasCancelled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static class GTimerTask extends TimerTask implements GTimerMonitor {
|
||||
|
||||
private final Runnable runnable;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -17,10 +16,32 @@
|
|||
package ghidra.util.timer;
|
||||
|
||||
/**
|
||||
* Monitor object returned from a GTimer.schedule() call
|
||||
*
|
||||
* Monitor object returned from a GTimer.schedule() call
|
||||
*/
|
||||
public interface GTimerMonitor {
|
||||
|
||||
/**
|
||||
* A dummy implementation of this interface
|
||||
*/
|
||||
public static GTimerMonitor DUMMY =
|
||||
new GTimerMonitor() {
|
||||
|
||||
@Override
|
||||
public boolean wasCancelled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean didRun() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean cancel() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Cancels the scheduled runnable associated with this GTimerMonitor if it has not already run.
|
||||
* @return true if the scheduled runnable was cancelled before it had a chance to execute.
|
||||
|
@ -35,7 +56,7 @@ public interface GTimerMonitor {
|
|||
|
||||
/**
|
||||
* Return true if the scheduled runnable was cancelled before it had a chance to run.
|
||||
* @return
|
||||
* @return true if the scheduled runnable was cancelled before it had a chance to run.
|
||||
*/
|
||||
public boolean wasCancelled();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue