Package qupath.lib.plugins
Class TaskRunnerUtils
java.lang.Object
qupath.lib.plugins.TaskRunnerUtils
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 Summary
Modifier and TypeMethodDescriptionCreate a new headlessTaskRunner
instance, using the default number of threads fromThreadTools.getParallelism()
.createHeadlessTaskRunner
(int nThreads) Create a new headlessTaskRunner
instance with the specified number of threads.Create a newTaskRunner
instance, using the default number of threads fromThreadTools.getParallelism()
.createTaskRunner
(int nThreads) Create a newTaskRunner
instance with the specified number of threads.static IntFunction
<TaskRunner> Get the default function used to createTaskRunner
instances.static TaskRunnerUtils
Get the default instance.static TaskRunnerUtils
Create a new instance.setCreateFunction
(IntFunction<TaskRunner> function) Set the function used to generate new headlessTaskRunner
instances.setCreateHeadlessFunction
(IntFunction<TaskRunner> function) Set the function used to generate newTaskRunner
instances.
-
Method Details
-
getDefaultInstance
Get the default instance. This is a singleton, shared across an application.- Returns:
-
newInstance
Create a new instance. This may be used if part of an application requires itsTaskRunner
instances to differ from those used elsewhere.- Returns:
-
getDefaultCreateFunction
Get the default function used to createTaskRunner
instances. This is suitable for use in a headless environment.- Returns:
-
setCreateHeadlessFunction
Set the function used to generate newTaskRunner
instances.- Parameters:
function
- a creator function that takes a requested number of threads as input- Returns:
- this instance
-
setCreateFunction
Set the function used to generate new headlessTaskRunner
instances.- Parameters:
function
- a creator function that takes a requested number of threads as input- Returns:
- this instance
-
createTaskRunner
Create a newTaskRunner
instance, using the default number of threads fromThreadTools.getParallelism()
. The task runner may support headless use, but does not have to.- Returns:
-
createTaskRunner
Create a newTaskRunner
instance with the specified number of threads. The task runner may support headless use, but does not have to.- Parameters:
nThreads
-- Returns:
-
createHeadlessTaskRunner
Create a new headlessTaskRunner
instance, using the default number of threads fromThreadTools.getParallelism()
.- Returns:
-
createHeadlessTaskRunner
Create a new headlessTaskRunner
instance with the specified number of threads.- Parameters:
nThreads
-- Returns:
-