Interface Scheduler

All Superinterfaces:
Executor

public interface Scheduler extends Executor
Utility for scheduling tasks
  • Method Summary

    Modifier and Type
    Method
    Description
    default <T> @NotNull Promise<T>
    call(@NotNull Callable<T> callable)
    Compute the result of the passed callable.
    default <T> @NotNull Promise<T>
    callLater(@NotNull Callable<T> callable, long delayTicks)
    Compute the result of the passed callable at some point in the future
    default <T> @NotNull Promise<T>
    callLater(@NotNull Callable<T> callable, long delay, @NotNull TimeUnit unit)
    Compute the result of the passed callable at some point in the future
    @NotNull ThreadContext
    Gets the context this scheduler operates in.
    default @NotNull Promise<Void>
    run(@NotNull Runnable runnable)
    Execute the passed runnable
    default @NotNull Promise<Void>
    runLater(@NotNull Runnable runnable, long delayTicks)
    Execute the passed runnable at some point in the future
    default @NotNull Promise<Void>
    runLater(@NotNull Runnable runnable, long delay, @NotNull TimeUnit unit)
    Execute the passed runnable at some point in the future
    default @NotNull Task
    runRepeating(@NotNull Runnable runnable, long delayTicks, long intervalTicks)
    Schedule a repeating task to run
    default @NotNull Task
    runRepeating(@NotNull Runnable runnable, long delay, @NotNull TimeUnit delayUnit, long interval, @NotNull TimeUnit intervalUnit)
    Schedule a repeating task to run
    @NotNull Task
    runRepeating(@NotNull Consumer<Task> consumer, long delayTicks, long intervalTicks)
    Schedule a repeating task to run
    @NotNull Task
    runRepeating(@NotNull Consumer<Task> consumer, long delay, @NotNull TimeUnit delayUnit, long interval, @NotNull TimeUnit intervalUnit)
    Schedule a repeating task to run
    default <T> @NotNull Promise<T>
    supply(@NotNull Supplier<T> supplier)
    Compute the result of the passed supplier.
    default <T> @NotNull Promise<T>
    supplyLater(@NotNull Supplier<T> supplier, long delayTicks)
    Compute the result of the passed supplier at some point in the future
    default <T> @NotNull Promise<T>
    supplyLater(@NotNull Supplier<T> supplier, long delay, @NotNull TimeUnit unit)
    Compute the result of the passed supplier at some point in the future

    Methods inherited from interface java.util.concurrent.Executor

    execute
  • Method Details

    • getContext

      @NotNull @NotNull ThreadContext getContext()
      Gets the context this scheduler operates in.
      Returns:
      the context
    • supply

      @NotNull default <T> @NotNull Promise<T> supply(@NotNull @NotNull Supplier<T> supplier)
      Compute the result of the passed supplier.
      Type Parameters:
      T - the return type
      Parameters:
      supplier - the supplier
      Returns:
      a Promise which will return the result of the computation
    • call

      @NotNull default <T> @NotNull Promise<T> call(@NotNull @NotNull Callable<T> callable)
      Compute the result of the passed callable.
      Type Parameters:
      T - the return type
      Parameters:
      callable - the callable
      Returns:
      a Promise which will return the result of the computation
    • run

      @NotNull default @NotNull Promise<Void> run(@NotNull @NotNull Runnable runnable)
      Execute the passed runnable
      Parameters:
      runnable - the runnable
      Returns:
      a Promise which will return when the runnable is complete
    • supplyLater

      @NotNull default <T> @NotNull Promise<T> supplyLater(@NotNull @NotNull Supplier<T> supplier, long delayTicks)
      Compute the result of the passed supplier at some point in the future
      Type Parameters:
      T - the return type
      Parameters:
      supplier - the supplier
      delayTicks - the delay in ticks before calling the supplier
      Returns:
      a Promise which will return the result of the computation
    • supplyLater

      @NotNull default <T> @NotNull Promise<T> supplyLater(@NotNull @NotNull Supplier<T> supplier, long delay, @NotNull @NotNull TimeUnit unit)
      Compute the result of the passed supplier at some point in the future
      Type Parameters:
      T - the return type
      Parameters:
      supplier - the supplier
      delay - the delay to wait before calling the supplier
      unit - the unit of delay
      Returns:
      a Promise which will return the result of the computation
    • callLater

      @NotNull default <T> @NotNull Promise<T> callLater(@NotNull @NotNull Callable<T> callable, long delayTicks)
      Compute the result of the passed callable at some point in the future
      Type Parameters:
      T - the return type
      Parameters:
      callable - the callable
      delayTicks - the delay in ticks before calling the supplier
      Returns:
      a Promise which will return the result of the computation
    • callLater

      @NotNull default <T> @NotNull Promise<T> callLater(@NotNull @NotNull Callable<T> callable, long delay, @NotNull @NotNull TimeUnit unit)
      Compute the result of the passed callable at some point in the future
      Type Parameters:
      T - the return type
      Parameters:
      callable - the callable
      delay - the delay to wait before calling the supplier
      unit - the unit of delay
      Returns:
      a Promise which will return the result of the computation
    • runLater

      @NotNull default @NotNull Promise<Void> runLater(@NotNull @NotNull Runnable runnable, long delayTicks)
      Execute the passed runnable at some point in the future
      Parameters:
      runnable - the runnable
      delayTicks - the delay in ticks before calling the supplier
      Returns:
      a Promise which will return when the runnable is complete
    • runLater

      @NotNull default @NotNull Promise<Void> runLater(@NotNull @NotNull Runnable runnable, long delay, @NotNull @NotNull TimeUnit unit)
      Execute the passed runnable at some point in the future
      Parameters:
      runnable - the runnable
      delay - the delay to wait before calling the supplier
      unit - the unit of delay
      Returns:
      a Promise which will return when the runnable is complete
    • runRepeating

      @NotNull @NotNull Task runRepeating(@NotNull @NotNull Consumer<Task> consumer, long delayTicks, long intervalTicks)
      Schedule a repeating task to run
      Parameters:
      consumer - the task to run
      delayTicks - the delay before the task begins
      intervalTicks - the interval at which the task will repeat
      Returns:
      a task instance
    • runRepeating

      @NotNull @NotNull Task runRepeating(@NotNull @NotNull Consumer<Task> consumer, long delay, @NotNull @NotNull TimeUnit delayUnit, long interval, @NotNull @NotNull TimeUnit intervalUnit)
      Schedule a repeating task to run
      Parameters:
      consumer - the task to run
      delay - the delay before the task begins
      delayUnit - the unit of delay
      interval - the interval at which the task will repeat
      intervalUnit - the
      Returns:
      a task instance
    • runRepeating

      @NotNull default @NotNull Task runRepeating(@NotNull @NotNull Runnable runnable, long delayTicks, long intervalTicks)
      Schedule a repeating task to run
      Parameters:
      runnable - the task to run
      delayTicks - the delay before the task begins
      intervalTicks - the interval at which the task will repeat
      Returns:
      a task instance
    • runRepeating

      @NotNull default @NotNull Task runRepeating(@NotNull @NotNull Runnable runnable, long delay, @NotNull @NotNull TimeUnit delayUnit, long interval, @NotNull @NotNull TimeUnit intervalUnit)
      Schedule a repeating task to run
      Parameters:
      runnable - the task to run
      delay - the delay before the task begins
      delayUnit - the unit of delay
      interval - the interval at which the task will repeat
      intervalUnit - the
      Returns:
      a task instance