Class TaskProvider

java.lang.Object
dev.crafty.core.task.providers.TaskProvider
All Implemented Interfaces:
Task

public class TaskProvider extends Object implements Task
Since:
1.0.0
  • Constructor Details

    • TaskProvider

      public TaskProvider()
  • Method Details

    • run

      public <T> void run(Callable<T> action, Consumer<T> onSuccess, TargetThread targetThread)
      Description copied from interface: Task
      Executes a given task on a specified target thread and returns the result.
      Specified by:
      run in interface Task
      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 success
      targetThread - 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: Task
      Executes a given task on a specified target thread and returns the result.
      Specified by:
      run in interface Task
      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 success
      onFailure - The action to be run on failure
      targetThread - The thread on which the task should be executed.
    • run

      public void run(Runnable action, TargetThread targetThread)
      Description copied from interface: Task
      Executes a given task on a specified target thread.
      Specified by:
      run in interface Task
      Parameters:
      action - The runnable task to be executed. This task will be executed on the specified thread.
      targetThread - The thread on which the task should be executed. This specifies the execution context for the task.
    • schedule

      public <T> void schedule(Callable<T> action, Consumer<T> onSuccess, UnitNumber<TimeUnit> delay, TargetThread targetThread)
      Description copied from interface: Task
      Schedules a task for execution on a specified target thread after a specified delay and returns the result of the task execution.
      Specified by:
      schedule in interface Task
      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, UnitNumber<TimeUnit> delay, TargetThread targetThread)
      Description copied from interface: Task
      Schedules a task for execution on a specified target thread after a specified delay and returns the result of the task execution.
      Specified by:
      schedule in interface Task
      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

      public void schedule(Runnable action, @NotNull @NotNull UnitNumber<TimeUnit> delay, TargetThread targetThread)
      Description copied from interface: Task
      Schedules a task for execution on a specified target thread after a specified delay.
      Specified by:
      schedule in interface Task
      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.