Class BatchRunnable

java.lang.Object
me.hsgamer.hscore.task.BatchRunnable
All Implemented Interfaces:
Runnable

public class BatchRunnable extends Object implements Runnable
A runnable that runs a batch of tasks in sequence
  • Constructor Details

    • BatchRunnable

      public BatchRunnable(TaskData data)
      Create a new batch runnable
      Parameters:
      data - the data
    • BatchRunnable

      public BatchRunnable()
      Create a new batch runnable with the default data storage
      See Also:
  • Method Details

    • run

      public void run()
      Specified by:
      run in interface Runnable
    • getTaskPool

      public TaskPool getTaskPool(int stage)
      Get the task pool
      Parameters:
      stage - the stage of the task pool
      Returns:
      the task pool
    • addTaskPool

      public void addTaskPool(int stage, Consumer<TaskPool> taskPoolConsumer)
      Execute the consumer for the task pool
      Parameters:
      stage - the stage of the task pool
      taskPoolConsumer - the consumer
    • setTimeout

      public void setTimeout(long timeout, TimeUnit unit)
      Set the timeout for each task
      Parameters:
      timeout - the timeout
      unit - the unit of the timeout
    • isTimeout

      public boolean isTimeout()
      Check if the task is interrupted by the timeout
      Returns:
      true if it is
    • getData

      public TaskData getData()
      Get the data
      Returns:
      the data