Class ExecutionPlanner
- java.lang.Object
-
- org.hortonmachine.gears.libs.modules.multiprocessing.ExecutionPlanner
-
- Direct Known Subclasses:
FixedChunkSizePlanner,InThreadExecutionPlanner
public abstract class ExecutionPlanner extends Object
AnExecutionPlannerprovides the logic to distribute the processing of many smallMultiProcessingTasks over a limited number of execution threads. This is crucial for efficient parallel execution.- Author:
- Falko Bräutigam
-
-
Field Summary
Fields Modifier and Type Field Description static BlockingExecutorServicedefaultExecutorThe defaultExecutorServiceto be used by all planners.static Supplier<ExecutionPlanner>defaultPlannerFactorySet this to change the default planner for all modules.protected intnumberOfTasks
-
Constructor Summary
Constructors Constructor Description ExecutionPlanner()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static ExecutionPlannercreateDefaultPlanner()Creates a new general purpose, defaultExecutionPlanner.abstract voidjoin()Blocks the calling thread until all sumitted task have completed execution.ExecutionPlannersetNumberOfTasks(int num)Hints this planner about the total number of task until nextjoin().abstract voidsubmit(MultiProcessingTask task)Submits the given task for execution.
-
-
-
Field Detail
-
defaultExecutor
public static final BlockingExecutorService defaultExecutor
The defaultExecutorServiceto be used by all planners. Set this to change the default. TheExecutorServicemust not have an unbound queue or an unlimited number of threads. In other words, the executor has to refuse submits when system resources are running out.
-
defaultPlannerFactory
public static Supplier<ExecutionPlanner> defaultPlannerFactory
Set this to change the default planner for all modules.
-
numberOfTasks
protected int numberOfTasks
-
-
Method Detail
-
createDefaultPlanner
public static ExecutionPlanner createDefaultPlanner()
Creates a new general purpose, defaultExecutionPlanner. This is returned byMultiProcessing.createDefaultPlanner()by default.
-
setNumberOfTasks
public ExecutionPlanner setNumberOfTasks(int num)
Hints this planner about the total number of task until nextjoin().
-
submit
public abstract void submit(MultiProcessingTask task)
Submits the given task for execution.- Parameters:
task-
-
-