Class ParallelTaskExecutor
java.lang.Object
dev.engine_room.flywheel.impl.task.ParallelTaskExecutor
- All Implemented Interfaces:
dev.engine_room.flywheel.api.task.TaskExecutor,TaskExecutorImpl,Executor
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidSpawns a number of work-stealing threads to process results in the task queue.voidvoidWait for all running tasks to finish.booleansyncUntil(BooleanSupplier cond) Wait for running tasks, until the given condition is met (BooleanSupplier.getAsBoolean()returnstrue).booleansyncWhile(BooleanSupplier cond) Wait for running tasks, so long as the given condition is met (BooleanSupplier.getAsBoolean()returnstrue).int
-
Constructor Details
-
ParallelTaskExecutor
-
-
Method Details
-
threadCount
public int threadCount()- Specified by:
threadCountin interfacedev.engine_room.flywheel.api.task.TaskExecutor
-
startWorkers
public void startWorkers()Spawns a number of work-stealing threads to process results in the task queue. If the executor is already running, this method does nothing and exits. -
stopWorkers
public void stopWorkers() -
execute
-
syncUntil
Description copied from interface:TaskExecutorImplWait for running tasks, until the given condition is met (BooleanSupplier.getAsBoolean()returnstrue).
This method is equivalent tosyncWhile(() -> !cond.getAsBoolean()).- Specified by:
syncUntilin interfaceTaskExecutorImpl- Parameters:
cond- The condition to wait for.- Returns:
trueif the condition is met.falseif this executor runs out of tasks before the condition is met.
-
syncWhile
Description copied from interface:TaskExecutorImplWait for running tasks, so long as the given condition is met (BooleanSupplier.getAsBoolean()returnstrue).
If this method is called on the
This method is equivalent tosyncUntil(() -> !cond.getAsBoolean()).- Specified by:
syncWhilein interfaceTaskExecutorImpl- Parameters:
cond- The condition sync on.- Returns:
trueif the condition is no longer met.falseif this executor runs out of tasks while the condition is still met.
-
syncPoint
public void syncPoint()Description copied from interface:TaskExecutorImplWait for all running tasks to finish.
This is useful as a nuclear option, but most of the time you should try to usesyncUntil.- Specified by:
syncPointin interfaceTaskExecutorImpl
-