Class AbstractTaskRunner

java.lang.Object
qupath.lib.plugins.AbstractTaskRunner
All Implemented Interfaces:
TaskRunner
Direct Known Subclasses:
CommandLineTaskRunner, TaskRunnerFX

public abstract class AbstractTaskRunner extends Object implements TaskRunner
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 Details

    • AbstractTaskRunner

      protected AbstractTaskRunner()
      Constructor for a PluginRunner that uses the default number of threads, read from ThreadTools.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 by ThreadTools.getParallelism().
  • Method Details

    • makeProgressMonitor

      protected abstract SimpleProgressMonitor makeProgressMonitor()
      Create a progress monitor to update the user on what is happening.
      Returns:
    • runTasks

      public void runTasks(Collection<? extends Runnable> tasks)
      Description copied from interface: TaskRunner
      Pass a collection of parallelizable tasks to run.
      Specified by:
      runTasks in interface TaskRunner
      Parameters:
      tasks - the tasks to run. If these are instances of PathTask 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

      protected void postProcess(Collection<? extends PathTask> tasks)
      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 interface TaskRunner
      Returns: