Class SerialTaskExecutor
java.lang.Object
dev.engine_room.flywheel.impl.task.SerialTaskExecutor
- All Implemented Interfaces:
dev.engine_room.flywheel.api.task.TaskExecutor,TaskExecutorImpl,Executor
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidWait 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
-
Field Details
-
INSTANCE
-
-
Method Details
-
execute
-
threadCount
public int threadCount()- Specified by:
threadCountin interfacedev.engine_room.flywheel.api.task.TaskExecutor
-
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
-