Package dev.crafty.core.task.providers
Class TaskProvider
java.lang.Object
dev.crafty.core.task.providers.TaskProvider
- All Implemented Interfaces:
Task
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidrun(Runnable action, TargetThread targetThread) Executes a given task on a specified target thread.<T> voidrun(Callable<T> action, Consumer<T> onSuccess, TargetThread targetThread) Executes a given task on a specified target thread and returns the result.<T> voidrun(Callable<T> action, Consumer<T> onSuccess, Runnable onFailure, TargetThread targetThread) Executes a given task on a specified target thread and returns the result.voidschedule(Runnable action, @NotNull Duration delay, TargetThread targetThread) Schedules a task for execution on a specified target thread after a specified delay.<T> voidschedule(Callable<T> action, Consumer<T> onSuccess, Runnable onFailure, Duration delay, TargetThread targetThread) Schedules a task for execution on a specified target thread after a specified delay and returns the result of the task execution.<T> voidschedule(Callable<T> action, Consumer<T> onSuccess, Duration delay, TargetThread targetThread) Schedules a task for execution on a specified target thread after a specified delay and returns the result of the task execution.
-
Constructor Details
-
TaskProvider
public TaskProvider()
-
-
Method Details
-
run
Description copied from interface:TaskExecutes a given task on a specified target thread and returns the result.- Specified by:
runin interfaceTask- Type Parameters:
T- The type of the result produced by the task.- Parameters:
action- The supplier representing the task to be executed. This task will be executed on the specified thread.onSuccess- The action to be run on successtargetThread- The thread on which the task should be executed.
-
run
public <T> void run(Callable<T> action, Consumer<T> onSuccess, Runnable onFailure, TargetThread targetThread) Description copied from interface:TaskExecutes a given task on a specified target thread and returns the result.- Specified by:
runin interfaceTask- Type Parameters:
T- The type of the result produced by the task.- Parameters:
action- The supplier representing the task to be executed. This task will be executed on the specified thread.onSuccess- The action to be run on successonFailure- The action to be run on failuretargetThread- The thread on which the task should be executed.
-
run
Description copied from interface:TaskExecutes a given task on a specified target thread. -
schedule
public <T> void schedule(Callable<T> action, Consumer<T> onSuccess, Duration delay, TargetThread targetThread) Description copied from interface:TaskSchedules a task for execution on a specified target thread after a specified delay and returns the result of the task execution.- Specified by:
schedulein interfaceTask- Type Parameters:
T- The type of the result produced by the task.- Parameters:
action- The supplier representing the task to be executed. This task will be executed on the specified thread after the delay.onSuccess- The action to be run when the task is complete.delay- The delay before the task is executed.targetThread- The thread on which the task should be executed.
-
schedule
public <T> void schedule(Callable<T> action, Consumer<T> onSuccess, Runnable onFailure, Duration delay, TargetThread targetThread) Description copied from interface:TaskSchedules a task for execution on a specified target thread after a specified delay and returns the result of the task execution.- Specified by:
schedulein interfaceTask- Type Parameters:
T- The type of the result produced by the task.- Parameters:
action- The supplier representing the task to be executed. This task will be executed on the specified thread after the delay.onSuccess- The action to be run when the task is complete.onFailure- The action to be run on failure.delay- The delay before the task is executed.targetThread- The thread on which the task should be executed.
-
schedule
Description copied from interface:TaskSchedules a task for execution on a specified target thread after a specified delay.- Specified by:
schedulein interfaceTask- Parameters:
action- The runnable task to be executed. This task will be scheduled to run on the specified thread after the delay period has elapsed.delay- The delay before the task is executed.targetThread- The thread on which the task should be executed. This specifies the execution context for the task.
-