diff options
Diffstat (limited to 'vespajlib/src/main/java/com/yahoo/concurrent/Timer.java')
-rw-r--r-- | vespajlib/src/main/java/com/yahoo/concurrent/Timer.java | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/vespajlib/src/main/java/com/yahoo/concurrent/Timer.java b/vespajlib/src/main/java/com/yahoo/concurrent/Timer.java index c41c762c989..46d72f6d5ad 100644 --- a/vespajlib/src/main/java/com/yahoo/concurrent/Timer.java +++ b/vespajlib/src/main/java/com/yahoo/concurrent/Timer.java @@ -20,7 +20,8 @@ public interface Timer { * @return The current value of the timer, in milliseconds. */ long milliTime(); - Timer monotonic = () -> TimeUnit.NANOSECONDS.toMillis(System.nanoTime()); + long creationNanos = System.nanoTime(); // Avoid monotonic timer overflow for the first 146 years of JVM uptime. + Timer monotonic = () -> TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - creationNanos); static Timer wrap(Clock original) { return new Timer() { private final Clock clock = original; @@ -30,6 +31,5 @@ public interface Timer { return clock.millis(); } }; } - default Instant instant() { return Instant.ofEpochMilli(milliTime()); } } |