Class RxTaskScheduler

java.lang.Object
com.mewna.catnip.util.scheduler.AbstractTaskScheduler
com.mewna.catnip.util.scheduler.RxTaskScheduler
All Implemented Interfaces:
Entity, RequiresCatnip, TaskScheduler

public class RxTaskScheduler extends AbstractTaskScheduler
Since:
7/29/19.
Author:
amy
  • Constructor Details

    • RxTaskScheduler

      public RxTaskScheduler()
  • Method Details

    • setTimer

      public long setTimer(long ms, @Nonnull Consumer<Long> task)
      Description copied from interface: TaskScheduler
      Schedules a new task to be run in the future.
      Parameters:
      ms - Delay, in milliseconds, before the task is run.
      task - The task to be run.
      Returns:
      The id of the task to be run. Used for cancellations.
    • setInterval

      public long setInterval(long ms, @Nonnull Consumer<Long> task)
      Description copied from interface: TaskScheduler
      Schedules a new task to be run on an interval.
      Parameters:
      ms - Interval, in milliseconds, between task runs.
      task - The task to be run.
      Returns:
      The id of the task to be run. Used for cancellations.
    • cancel

      public boolean cancel(long id)
      Description copied from interface: TaskScheduler
      Cancels the task with the supplied id.
      Parameters:
      id - The id of the task to cancel.
      Returns:
      true if the task was successfully cancelled, false otherwise.