Class SimplifiedEnhancedExecutor
java.lang.Object
space.arim.omnibus.util.concurrent.impl.SimplifiedEnhancedExecutor
- All Implemented Interfaces:
Executor, EnhancedExecutor
Abstract implementation of
Uses the system wide internal scheduler (
EnhancedExecutor which handles its own scheduling and delegates
execution to subclasses' execute(Runnable) methods. Uses the system wide internal scheduler (
CompletableFuture.delayedExecutor(long, TimeUnit, Executor))
to provide scheduling.- Author:
- A248
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract voidRuns the specified command.scheduleOnce(Runnable command, Duration delay) Schedules a delayed taskscheduleRepeating(Runnable command, Duration initialDelay, DelayCalculator delayCalculator) Schedules a repeating taskscheduleRepeating(Consumer<? super ScheduledTask> command, Duration initialDelay, DelayCalculator delayCalculator) Schedules a repeating taskExecute an asynchronous action using this executor.<T> CompletableFuture<T> Supplies a value asynchronously using this executor.
-
Constructor Details
-
SimplifiedEnhancedExecutor
protected SimplifiedEnhancedExecutor()Creates an instance
-
-
Method Details
-
execute
Runs the specified command.
It may run anywhere except the calling thread.- Specified by:
executein interfaceEnhancedExecutor- Specified by:
executein interfaceExecutor- Parameters:
command- the command
-
submit
Description copied from interface:EnhancedExecutorExecute an asynchronous action using this executor.
The returned future provides the ability to listen for completion or block until complete.- Specified by:
submitin interfaceEnhancedExecutor- Parameters:
command- theRunnableto run- Returns:
- a future completed when the command is run
-
supply
Description copied from interface:EnhancedExecutorSupplies a value asynchronously using this executor.- Specified by:
supplyin interfaceEnhancedExecutor- Type Parameters:
T- the type of the supplier- Parameters:
supplier- the supplier- Returns:
- a future which yields the result of the supplier
-
scheduleOnce
Description copied from interface:EnhancedExecutorSchedules a delayed task- Specified by:
scheduleOncein interfaceEnhancedExecutor- Parameters:
command- the runnable to rundelay- the duration after which to commence execution- Returns:
- a scheduled task for the delayed work, which may be cancelled before execution begins
-
scheduleRepeating
public ScheduledTask scheduleRepeating(Runnable command, Duration initialDelay, DelayCalculator delayCalculator) Description copied from interface:EnhancedExecutorSchedules a repeating task- Specified by:
scheduleRepeatingin interfaceEnhancedExecutor- Parameters:
command- the runnable to runinitialDelay- the initial delay before the first execution beginsdelayCalculator- the delay calculator to calculate repeated delays- Returns:
- a scheduled task for the repeating work, which may be cancelled
-
scheduleRepeating
public ScheduledTask scheduleRepeating(Consumer<? super ScheduledTask> command, Duration initialDelay, DelayCalculator delayCalculator) Description copied from interface:EnhancedExecutorSchedules a repeating task- Specified by:
scheduleRepeatingin interfaceEnhancedExecutor- Parameters:
command- the consumer to runinitialDelay- the initial delay before the first execution beginsdelayCalculator- the delay calculator to calculate repeated delays- Returns:
- a scheduled task representing the repeating work, which may be cancelled
-