Interface TaskScheduler
- All Superinterfaces:
AutoCloseable
Provides executors for CPU-bound and IO-bound tasks.
-
Method Summary
Modifier and TypeMethodDescriptiondefault Executorasync()Default async executor (CPU by default).default voidclose()cpu()Executor for CPU-heavy work.io()Executor for blocking IO work.default CompletableFuture<Void> Run a task on the default async executor.default CompletableFuture<Void> Run a task on the CPU executor.default CompletableFuture<Void> Run a task on the IO executor.Scheduler for delayed tasks.voidshutdown()Shutdown all executors.default <T> CompletableFuture<T> supplyAsync(Supplier<T> supplier) Supply a value on the default async executor.default <T> CompletableFuture<T> Supply a value on the CPU executor.default <T> CompletableFuture<T> Supply a value on the IO executor.
-
Method Details
-
cpu
-
io
-
scheduler
-
async
-
runCpu
Run a task on the CPU executor.- Parameters:
task- task to run- Returns:
- future for completion
-
runIo
Run a task on the IO executor.- Parameters:
task- task to run- Returns:
- future for completion
-
runAsync
Run a task on the default async executor.- Parameters:
task- task to run- Returns:
- future for completion
-
supplyCpu
Supply a value on the CPU executor.- Type Parameters:
T- value type- Parameters:
supplier- value supplier- Returns:
- future for result
-
supplyIo
Supply a value on the IO executor.- Type Parameters:
T- value type- Parameters:
supplier- value supplier- Returns:
- future for result
-
supplyAsync
Supply a value on the default async executor.- Type Parameters:
T- value type- Parameters:
supplier- value supplier- Returns:
- future for result
-
shutdown
void shutdown()Shutdown all executors. -
close
default void close()- Specified by:
closein interfaceAutoCloseable
-