Interface Task

All Known Subinterfaces:
BlockingTask
All Known Implementing Classes:
BackgroundTask, ForegroundTask

public interface Task
A task defines a piece of code that may be executed - in the foreground or background - within a certain budget that is specific to the task type.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static enum 
     
  • Method Summary

    Modifier and Type
    Method
    Description
    How long it took to run the task when the task was completed
    long
    The current computed delay.
    long
    The current elapsed time.
    The task failed for some un-expected exception
    long
    The time the first attempt was performed.
    long
    The time the last attempt has been performed.
    Optional name of the task
    long
    An indication about the time the next attempt will be made.
    Gets the task status.
    default boolean
    Whether the task is currently attempting to run its supplier (true), or waiting for the next scheduled tick (false).
    int
    The current number of iterations (such as when the task is being repeated)
  • Method Details

    • getName

      String getName()
      Optional name of the task
    • getStatus

      Task.Status getStatus()
      Gets the task status.
    • elapsed

      Duration elapsed()
      How long it took to run the task when the task was completed
      Returns:
      The duration to execute the task
    • iteration

      int iteration()
      The current number of iterations (such as when the task is being repeated)
      Returns:
      the current number of iterations
    • getCurrentDelay

      long getCurrentDelay()
      The current computed delay.
    • getCurrentElapsedTime

      long getCurrentElapsedTime()
      The current elapsed time.
    • getFirstAttemptTime

      long getFirstAttemptTime()
      The time the first attempt was performed.
    • getLastAttemptTime

      long getLastAttemptTime()
      The time the last attempt has been performed.
    • getNextAttemptTime

      long getNextAttemptTime()
      An indication about the time the next attempt will be made.
    • isAttempting

      default boolean isAttempting()
      Whether the task is currently attempting to run its supplier (true), or waiting for the next scheduled tick (false).
    • getException

      Throwable getException()
      The task failed for some un-expected exception