Package ghidra.framework.plugintool.mgr
Class ToolTaskManager
java.lang.Object
ghidra.framework.plugintool.mgr.ToolTaskManager
- All Implemented Interfaces:
Runnable
Manages a queue of background tasks that execute commands.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Cancel the current task.void
Clear the queue of scheduled commands.void
Clear the list of tasks.void
clearTasks
(DomainObject obj) Clear all tasks associated with specified domain object.void
dispose()
Clear list of tasks and queue of scheduled commands.<T extends DomainObject>
booleanExecute the given command in the foreground.<T extends DomainObject>
booleanExecute the given command in the foreground.<T extends DomainObject>
voidexecuteCommand
(BackgroundCommand<T> cmd, T obj) Execute the given command in the backgroundGet the monitor component that shows progress and has a cancel button.Returns the thread group associated with all background tasks run by this manager and their instantiated threads.boolean
hasTasksForDomainObject
(DomainObject domainObject) boolean
isBusy()
Return true if a task is executingvoid
run()
<T extends DomainObject>
voidscheduleFollowOnCommand
(BackgroundCommand<T> cmd, T obj) Schedule the given background command when the current command completes.void
stop
(TaskMonitor monitor) Cancel the currently running task and clear all commands that are scheduled to run.<T extends DomainObject>
voidtaskCompleted
(T obj, ghidra.framework.plugintool.mgr.BackgroundCommandTask<T> task, TaskMonitor monitor) Notification from the BackgroundCommandTask that it has completed; queued or scheduled commands are executed.<T extends DomainObject>
voidtaskFailed
(T obj, BackgroundCommand<T> taskCmd, TaskMonitor monitor) Notification from the BackgroundCommandTask that the given command failed.
-
Constructor Details
-
ToolTaskManager
Construct a new ToolTaskManager.- Parameters:
tool
- tool associated with this ToolTaskManager
-
-
Method Details
-
getTaskThreadGroup
Returns the thread group associated with all background tasks run by this manager and their instantiated threads.- Returns:
- task thread group
-
getMonitorComponent
Get the monitor component that shows progress and has a cancel button.- Returns:
- the monitor component
-
isBusy
public boolean isBusy()Return true if a task is executing- Returns:
- true if a task is executing
-
execute
public <T extends DomainObject> boolean execute(String commandName, T domainObject, Function<T, Boolean> f) Execute the given command in the foreground. Required domain object transaction will be started with delayed end to ensure that any follow-on analysis starts prior to transaction end.- Type Parameters:
T
-DomainObject
implementation interface- Parameters:
commandName
- command name to be associated with transactiondomainObject
- domain object to be modifiedf
- command function callback which should return true on success or false on failure.- Returns:
- result from command function callback
-
execute
Execute the given command in the foreground. Required domain object transaction will be started with delayed end to ensure that any follow-on analysis starts prior to transaction end.- Parameters:
cmd
- command to executeobj
- domain object to which the command will be applied- Returns:
- the completion status of the command
- See Also:
-
executeCommand
Execute the given command in the background- Parameters:
cmd
- background commandobj
- domain object that supports undo/redo
-
scheduleFollowOnCommand
Schedule the given background command when the current command completes.- Parameters:
cmd
- background command to be scheduledobj
- domain object that supports undo/redo
-
stop
Cancel the currently running task and clear all commands that are scheduled to run. Block until the currently running task ends.- Parameters:
monitor
- a monitor to cancel waiting for the task to finish
-
run
public void run() -
taskCompleted
public <T extends DomainObject> void taskCompleted(T obj, ghidra.framework.plugintool.mgr.BackgroundCommandTask<T> task, TaskMonitor monitor) Notification from the BackgroundCommandTask that it has completed; queued or scheduled commands are executed.- Parameters:
obj
- domain object that supports undo/redotask
- background command task that has completedmonitor
- task monitor
-
clearQueuedCommands
Clear the queue of scheduled commands.- Parameters:
obj
- domain object
-
clearTasks
Clear all tasks associated with specified domain object.- Parameters:
obj
- domain object
-
taskFailed
public <T extends DomainObject> void taskFailed(T obj, BackgroundCommand<T> taskCmd, TaskMonitor monitor) Notification from the BackgroundCommandTask that the given command failed. Any scheduled commands are cleared from the queue.- Parameters:
obj
- domain object that supports undo/redotaskCmd
- background command that failedmonitor
- task monitor for the background task
-
dispose
public void dispose()Clear list of tasks and queue of scheduled commands. -
clearTasks
public void clearTasks()Clear the list of tasks. -
cancelCurrentTask
public void cancelCurrentTask()Cancel the current task. -
hasTasksForDomainObject
-