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
ConstructorsModifierConstructorDescriptionprotectedConstructor for a PluginRunner that uses the default number of threads, read fromThreadTools.getParallelism().protectedAbstractTaskRunner(int numThreads) Constructor for a PluginRunner that optionally uses a fixed number of threads. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidAwait the completion of currently-running tasks, notifying any listener if necessary.booleanQuery if the plugin can be cancelled while running.protected abstract SimpleProgressMonitorCreate a progress monitor to update the user on what is happening.protected voidpostProcess(Collection<? extends PathTask> tasks) Perform post-processing after a task has complete.voidrunTasks(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:TaskRunnerPass a collection of parallelizable tasks to run.- Specified by:
runTasksin interfaceTaskRunner- Parameters:
tasks- the tasks to run. If these are instances ofPathTaskthen 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:TaskRunnerQuery if the plugin can be cancelled while running. Plugins are expected to check this flag before time-consuming operations.- Specified by:
isCancelledin interfaceTaskRunner- Returns:
-