Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tspace monotonic #571

Merged
merged 2 commits into from
Nov 24, 2023
Merged

Tspace monotonic #571

merged 2 commits into from
Nov 24, 2023

Conversation

barspi
Copy link
Contributor

@barspi barspi commented Nov 24, 2023

This is a resurrection of an old PR #418 by James Hilliard.

James' solution is based on System.nanoTime() which has a monotonical increasing behavior.
There's really no need for nano precision or resolution, and its value bears no relation to any actual calendar time or epoch. However, it's perfect to measure monotonically increasing elapsed time in order to expire space entries, for example.

His fix was important to avoid bugs in cases where the system clock (as typically given by System.currentTimeMillis() in the older implementation) may run backward because of daylight saving adjustments, or other weird NTP behavior.

However, I found the implementation a bit confusing, with unneeded usage of Duration to store "points in time" and complicated Duration operations. The complexity may have prevented the original merge of the PR, but it's still an important fix.

I attempted to go simpler, using naked System.nanoTime() and basic arithmetic as much as I could.

(there are other similar PRs for other classes that mesure elapsed time that will get fixed soon, if this is accepted)

@ar ar merged commit 98ae51d into jpos:master Nov 24, 2023
6 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants