Class FakeTicker

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private long autoIncrementStepNanos  
      private java.util.concurrent.atomic.AtomicLong nanos  
    • Constructor Summary

      Constructors 
      Constructor Description
      FakeTicker()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      FakeTicker advance​(long nanoseconds)
      Advances the ticker value by nanoseconds.
      FakeTicker advance​(long time, java.util.concurrent.TimeUnit timeUnit)
      Advances the ticker value by time in timeUnit.
      FakeTicker advance​(java.time.Duration duration)
      Advances the ticker value by duration.
      long read()
      Returns the number of nanoseconds elapsed since this ticker's fixed point of reference.
      FakeTicker setAutoIncrementStep​(long autoIncrementStep, java.util.concurrent.TimeUnit timeUnit)
      Sets the increment applied to the ticker whenever it is queried.
      FakeTicker setAutoIncrementStep​(java.time.Duration autoIncrementStep)
      Sets the increment applied to the ticker whenever it is queried.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • nanos

        private final java.util.concurrent.atomic.AtomicLong nanos
      • autoIncrementStepNanos

        private volatile long autoIncrementStepNanos
    • Constructor Detail

      • FakeTicker

        public FakeTicker()
    • Method Detail

      • advance

        public FakeTicker advance​(long time,
                                  java.util.concurrent.TimeUnit timeUnit)
        Advances the ticker value by time in timeUnit.
      • advance

        public FakeTicker advance​(long nanoseconds)
        Advances the ticker value by nanoseconds.
      • advance

        public FakeTicker advance​(java.time.Duration duration)
        Advances the ticker value by duration.
        Since:
        28.0
      • setAutoIncrementStep

        public FakeTicker setAutoIncrementStep​(long autoIncrementStep,
                                               java.util.concurrent.TimeUnit timeUnit)
        Sets the increment applied to the ticker whenever it is queried.

        The default behavior is to auto increment by zero. i.e: The ticker is left unchanged when queried.

      • setAutoIncrementStep

        public FakeTicker setAutoIncrementStep​(java.time.Duration autoIncrementStep)
        Sets the increment applied to the ticker whenever it is queried.

        The default behavior is to auto increment by zero. i.e: The ticker is left unchanged when queried.

        Since:
        28.0
      • read

        public long read()
        Description copied from class: Ticker
        Returns the number of nanoseconds elapsed since this ticker's fixed point of reference.
        Specified by:
        read in class Ticker