clj-commons / durable-queue

a disk-backed queue for clojure
Eclipse Public License 1.0
384 stars 31 forks source link

Use nanoTime instead of currentTimeMillis for elapsed time #21

Open danielcompton opened 5 years ago

danielcompton commented 5 years ago

System/currentTimeMillis is not guaranteed to progress monotonically. NTP shifts, leap seconds, and manual system time changes can all cause elapsed time calculations to be incorrect if you use currentTimeMillis.

nanoTime is always calculated against a fixed point and proceeds monotonically.

https://go.googlesource.com/proposal/+/master/design/12914-monotonic.md has a good discussion on monotonic time.