Interface Ticker

All Known Implementing Classes:
DisabledTicker, SystemTicker

public interface Ticker
A time source that returns a time value representing the number of nanoseconds elapsed since some fixed but arbitrary point in time.
  • Method Summary

    Modifier and Type
    Method
    Description
    static @NonNull Ticker
    Returns a ticker that always returns 0.
    long
    Returns the number of nanoseconds elapsed since this ticker's fixed point of reference.
    static @NonNull Ticker
    Returns a ticker that reads the current time using System.nanoTime().
  • Method Details

    • read

      long read()
      Returns the number of nanoseconds elapsed since this ticker's fixed point of reference.
      Returns:
      the number of nanoseconds elapsed since this ticker's fixed point of reference
    • systemTicker

      static @NonNull Ticker systemTicker()
      Returns a ticker that reads the current time using System.nanoTime().
      Returns:
      a ticker that reads the current time using System.nanoTime()
    • disabledTicker

      static @NonNull Ticker disabledTicker()
      Returns a ticker that always returns 0.
      Returns:
      a ticker that always returns 0