Class PseudoClock


  • public class PseudoClock
    extends java.lang.Object
    Singleton used to track and control time independently of the system clock. This class is currently shared by implementations and test APIs to help share the same reference point to time.
    Author:
    jwhite
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      long advanceTime​(long duration, java.util.concurrent.TimeUnit unit)
      Advances the clock time
      static PseudoClock getInstance()  
      long getTime()
      Retrieves the current time.
      void reset()
      Resets the clock time to zero.
      • Methods inherited from class java.lang.Object

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

      • getInstance

        public static PseudoClock getInstance()
      • reset

        public void reset()
        Resets the clock time to zero.
      • getTime

        public long getTime()
        Retrieves the current time.
        Returns:
        current timestamp in ms
      • advanceTime

        public long advanceTime​(long duration,
                                java.util.concurrent.TimeUnit unit)
        Advances the clock time
        Parameters:
        duration - duration of time in the given units
        unit - time unit
        Returns:
        the absolute timestamp of the clock, following the advance