Package qupath.lib.plugins
Class AbstractTaskRunner
java.lang.Object
qupath.lib.plugins.AbstractTaskRunner
- All Implemented Interfaces:
TaskRunner
- Direct Known Subclasses:
CommandLineTaskRunner
,TaskRunnerFX
Abstract PluginRunner to help with the creation of plugin runners for specific circumstances,
e.g. running through a GUI, or from a command line only.
-
Constructor Summary
ModifierConstructorDescriptionprotected
Constructor for a PluginRunner that uses the default number of threads, read fromThreadTools.getParallelism()
.protected
AbstractTaskRunner
(int numThreads) Constructor for a PluginRunner that optionally uses a fixed number of threads. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Await the completion of currently-running tasks, notifying any listener if necessary.boolean
Query if the plugin can be cancelled while running.protected abstract SimpleProgressMonitor
Create a progress monitor to update the user on what is happening.protected void
postProcess
(Collection<? extends PathTask> tasks) Perform post-processing after a task has complete.void
runTasks
(Collection<? extends Runnable> tasks) Pass a collection of parallelizable tasks to run.
-
Constructor Details
-
AbstractTaskRunner
protected AbstractTaskRunner()Constructor for a PluginRunner that uses the default number of threads, read fromThreadTools.getParallelism()
. -
AbstractTaskRunner
protected AbstractTaskRunner(int numThreads) Constructor for a PluginRunner that optionally uses a fixed number of threads.- Parameters:
numThreads
- the number of threads to use, or -1 to use the default number of threads defined byThreadTools.getParallelism()
.
-
-
Method Details
-
makeProgressMonitor
Create a progress monitor to update the user on what is happening.- Returns:
-
runTasks
Description copied from interface:TaskRunner
Pass a collection of parallelizable tasks to run.- Specified by:
runTasks
in interfaceTaskRunner
- Parameters:
tasks
- the tasks to run. If these are instances ofPathTask
then an optional postprocessing may be applied after all tasks are complete.
-
awaitCompletion
protected void awaitCompletion()Await the completion of currently-running tasks, notifying any listener if necessary. -
postProcess
Perform post-processing after a task has complete. This is necessary to call the taskComplete method (if the Runnable is an instance of PathTask), and also to update any progress monitor. Note: Subclasses may choose to override this method so that it is called on a particular thread (e.g. with Platform.runLater() or SwingUtilities.invokeLater).- Parameters:
tasks
-
-
isCancelled
public boolean isCancelled()Description copied from interface:TaskRunner
Query if the plugin can be cancelled while running. Plugins are expected to check this flag before time-consuming operations.- Specified by:
isCancelled
in interfaceTaskRunner
- Returns:
-