Interface TaskExecutor

All Superinterfaces:
Executor, TickAdapter
All Known Subinterfaces:
AsyncExecutor, SyncExecutor
All Known Implementing Classes:
AbstractSyncExecutor, SimpleAsyncExecutor

public interface TaskExecutor extends TickAdapter, Executor
Represents a task executor.
  • Method Details

    • execute

      default void execute(Runnable command)
      Specified by:
      execute in interface Executor
    • submit

      default CompletableFuture<?> submit(Runnable task)
      Submit a task.
      Parameters:
      task - the task to submit
      Returns:
      the scheduled task
    • submit

      default <V> CompletableFuture<@PolyNull V> submit(Supplier<@PolyNull V> task)
      Submit a task.
      Type Parameters:
      V - the type of result the task returns
      Parameters:
      task - the task to submit
      Returns:
      the scheduled task as a future
    • submit

      default CompletableFuture<?> submit(Runnable task, int ticks)
      Submit a task.
      Parameters:
      task - the task to submit
      ticks - the delay before the task is executed in game ticks
      Returns:
      the scheduled task as a future
    • submit

      <V> CompletableFuture<@PolyNull V> submit(Supplier<@PolyNull V> task, int ticks)
      Submit a task.
      Type Parameters:
      V - the type of result the task returns
      Parameters:
      task - the task to submit
      ticks - the delay before the task is executed in game ticks
      Returns:
      the scheduled task as a future
    • submit

      default CompletableFuture<?> submit(Runnable task, long delay, TimeUnit unit)
      Submit a task.
      Parameters:
      task - the task to submit
      delay - the delay before the task is executed
      unit - the unit of time for delay
      Returns:
      the scheduled task as a future
    • submit

      <V> CompletableFuture<@PolyNull V> submit(Supplier<@PolyNull V> task, long delay, TimeUnit unit)
      Submit a task.
      Type Parameters:
      V - the type of result the task returns
      Parameters:
      task - the task to submit
      delay - the delay before the task is executed
      unit - the unit of time for delay
      Returns:
      the scheduled task as a future
    • repeat

      default Task repeat(Runnable task, int periodTicks)
      Schedule a repeating task.
      Parameters:
      task - the task to schedule
      periodTicks - how often to repeat the task in game ticks
      Returns:
      the scheduled task
    • repeat

      default Task repeat(Runnable task, long period, TimeUnit unit)
      Schedule a repeating task.
      Parameters:
      task - the task to schedule
      period - how often to repeat the task
      unit - the unit of time for period
      Returns:
      the scheduled task
    • repeat

      Task repeat(Runnable task, int ticks, int periodTicks)
      Schedule a repeating task.
      Parameters:
      task - the task to schedule
      ticks - the delay before the first task execution in game ticks
      periodTicks - how often to repeat the task in game ticks
      Returns:
      the scheduled task
    • repeat

      Task repeat(Runnable task, long delay, long period, TimeUnit unit)
      Schedule a repeating task.
      Parameters:
      task - the task to schedule
      delay - the delay before the first task execution
      period - how often to repeat the task
      unit - the unit of time for delay and period
      Returns:
      the scheduled task
    • isValid

      boolean isValid()
      Check whether this executor can currently schedule and execute tasks. This should return false if it hasn't been initialized or has been terminated.
      Returns:
      whether tasks can be scheduled and executed
    • shutdown

      void shutdown()
      Safely shutdown this executor.