Package emu.grasscutter.server.scheduler
Class AsyncServerTask
java.lang.Object
emu.grasscutter.server.scheduler.AsyncServerTask
- All Implemented Interfaces:
Runnable
A server task that should be run asynchronously.
-
Constructor Summary
ConstructorsConstructorDescriptionAsyncServerTask(Runnable task, int taskId) For tasks without a callback.AsyncServerTask(Runnable task, Runnable callback, int taskId) For tasks with a callback. -
Method Summary
-
Constructor Details
-
AsyncServerTask
For tasks without a callback.- Parameters:
task- The task to run.
-
AsyncServerTask
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. -
complete
public void complete()Runs the callback. -
setResult
Sets the result of the async task.- Parameters:
result- The result of the async task.
-
getResult
Returns the set result of the async task.- Returns:
- The result, or null if it has not been set.
-
getTaskId
public int getTaskId()
-