Interface TaskScheduler

All Superinterfaces:
AutoCloseable

public interface TaskScheduler extends AutoCloseable
Provides executors for CPU-bound and IO-bound tasks.
  • Method Details

    • cpu

      Executor cpu()
      Executor for CPU-heavy work.
      Returns:
      CPU executor
    • io

      Executor io()
      Executor for blocking IO work.
      Returns:
      IO executor
    • scheduler

      Scheduler for delayed tasks.
      Returns:
      scheduled executor
    • async

      default Executor async()
      Default async executor (CPU by default).
      Returns:
      async executor
    • runCpu

      default CompletableFuture<Void> runCpu(Runnable task)
      Run a task on the CPU executor.
      Parameters:
      task - task to run
      Returns:
      future for completion
    • runIo

      default CompletableFuture<Void> runIo(Runnable task)
      Run a task on the IO executor.
      Parameters:
      task - task to run
      Returns:
      future for completion
    • runAsync

      default CompletableFuture<Void> runAsync(Runnable task)
      Run a task on the default async executor.
      Parameters:
      task - task to run
      Returns:
      future for completion
    • supplyCpu

      default <T> CompletableFuture<T> supplyCpu(Supplier<T> supplier)
      Supply a value on the CPU executor.
      Type Parameters:
      T - value type
      Parameters:
      supplier - value supplier
      Returns:
      future for result
    • supplyIo

      default <T> CompletableFuture<T> supplyIo(Supplier<T> supplier)
      Supply a value on the IO executor.
      Type Parameters:
      T - value type
      Parameters:
      supplier - value supplier
      Returns:
      future for result
    • supplyAsync

      default <T> CompletableFuture<T> supplyAsync(Supplier<T> supplier)
      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:
      close in interface AutoCloseable