Class Timer.Context

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable
    Enclosing class:
    Timer

    public static class Timer.Context
    extends java.lang.Object
    implements java.io.Closeable
    A timing context.
    See Also:
    Timer.time()
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private Context​(Timer timer, Clock clock)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      long stop()
      Stops recording the elapsed time, updates the timer and returns the elapsed time in nanoseconds.
      • Methods inherited from class java.lang.Object

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

      • timer

        private final Timer timer
      • clock

        private final Clock clock
      • startTime

        private final long startTime
    • Constructor Detail

      • Context

        private Context​(Timer timer,
                        Clock clock)
    • Method Detail

      • stop

        public long stop()
        Stops recording the elapsed time, updates the timer and returns the elapsed time in nanoseconds.
      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable