Class AsyncServerTask

java.lang.Object
emu.grasscutter.server.scheduler.AsyncServerTask
All Implemented Interfaces:
Runnable

public final class AsyncServerTask extends Object implements Runnable
A server task that should be run asynchronously.
  • Constructor Details

    • AsyncServerTask

      public AsyncServerTask(Runnable task, int taskId)
      For tasks without a callback.
      Parameters:
      task - The task to run.
    • AsyncServerTask

      public AsyncServerTask(Runnable task, @Nullable Runnable callback, int taskId)
      For tasks with a callback.
      Parameters:
      task - The task to run.
      callback - The task to run after the task is complete.
  • Method Details

    • hasStarted

      public boolean hasStarted()
      Returns the state of the task.
      Returns:
      True if the task has been started, false otherwise.
    • isFinished

      public boolean isFinished()
      Returns the state of the task.
      Returns:
      True if the task has finished execution, false otherwise.
    • run

      public void run()
      Runs the task.
      Specified by:
      run in interface Runnable
    • complete

      public void complete()
      Runs the callback.
    • setResult

      public void setResult(@Nullable Object result)
      Sets the result of the async task.
      Parameters:
      result - The result of the async task.
    • getResult

      @Nullable public Object getResult()
      Returns the set result of the async task.
      Returns:
      The result, or null if it has not been set.
    • getTaskId

      public int getTaskId()