Package monero.common

Class TaskLooper

java.lang.Object
monero.common.TaskLooper

public class TaskLooper extends Object
Run a task in a fixed period loop.
  • Constructor Details

    • TaskLooper

      public TaskLooper(Runnable task)
      Build the looper with a task to invoke on a fixed period loop.
      Parameters:
      task - is the task to invoke
  • Method Details

    • getTask

      public Runnable getTask()
      Get the runnable task to invoke on a fixed period loop.
      Returns:
      the runnable task
    • start

      public TaskLooper start(long periodInMs)
      Start the task loop.
      Parameters:
      periodInMs - the loop period in milliseconds
      Returns:
      this instance for chaining
    • start

      public TaskLooper start(long periodInMs, boolean targetFixedPeriod)
      Start the task loop.
      Parameters:
      periodInMs - the loop period in milliseconds
      targetFixedPeriod - specifies if the task should target a fixed period by accounting for run time
      Returns:
      this instance for chaining
    • isStarted

      public boolean isStarted()
      Indicates if looping.
      Returns:
      true if looping, false otherwise
    • stop

      public void stop()
      Stop the task loop.
    • setPeriodInMs

      public void setPeriodInMs(long periodInMs)
      Set the loop period in milliseconds.
      Parameters:
      periodInMs - the loop period in milliseconds