Class TaskRunnerUtils

java.lang.Object
qupath.lib.plugins.TaskRunnerUtils

public class TaskRunnerUtils extends Object
A utility class to help with the creation of TaskRunner instances.

An application can use setCreateFunction(IntFunction) and #setCreateHeadlessFunction(IntFunction)} to control the creation of TaskRunner instances.

Since:
v0.5.0
  • Method Details

    • getDefaultInstance

      public static TaskRunnerUtils getDefaultInstance()
      Get the default instance. This is a singleton, shared across an application.
      Returns:
    • newInstance

      public static TaskRunnerUtils newInstance()
      Create a new instance. This may be used if part of an application requires its TaskRunner instances to differ from those used elsewhere.
      Returns:
    • getDefaultCreateFunction

      public static IntFunction<TaskRunner> getDefaultCreateFunction()
      Get the default function used to create TaskRunner instances. This is suitable for use in a headless environment.
      Returns:
    • setCreateHeadlessFunction

      public TaskRunnerUtils setCreateHeadlessFunction(IntFunction<TaskRunner> function)
      Set the function used to generate new TaskRunner instances.
      Parameters:
      function - a creator function that takes a requested number of threads as input
      Returns:
      this instance
    • setCreateFunction

      public TaskRunnerUtils setCreateFunction(IntFunction<TaskRunner> function)
      Set the function used to generate new headless TaskRunner instances.
      Parameters:
      function - a creator function that takes a requested number of threads as input
      Returns:
      this instance
    • createTaskRunner

      public TaskRunner createTaskRunner()
      Create a new TaskRunner instance, using the default number of threads from ThreadTools.getParallelism(). The task runner may support headless use, but does not have to.
      Returns:
    • createTaskRunner

      public TaskRunner createTaskRunner(int nThreads)
      Create a new TaskRunner instance with the specified number of threads. The task runner may support headless use, but does not have to.
      Parameters:
      nThreads -
      Returns:
    • createHeadlessTaskRunner

      public TaskRunner createHeadlessTaskRunner()
      Create a new headless TaskRunner instance, using the default number of threads from ThreadTools.getParallelism().
      Returns:
    • createHeadlessTaskRunner

      public TaskRunner createHeadlessTaskRunner(int nThreads)
      Create a new headless TaskRunner instance with the specified number of threads.
      Parameters:
      nThreads -
      Returns: