Skip to content

Nano time for elapsed timings and Nats System Clock#1334

Merged
scottf merged 2 commits intomainfrom
timers-move-to-nano
Jun 20, 2025
Merged

Nano time for elapsed timings and Nats System Clock#1334
scottf merged 2 commits intomainfrom
timers-move-to-nano

Conversation

@scottf
Copy link
Contributor

@scottf scottf commented Jun 19, 2025

  • Created the NatsSystemClock and the NatsSystemClockProvider.
    • The NatsSystemClock is a replacement for System in regard to the clock.
    • All NatsSystemClock's public methods are static.
    • By default it uses System.nanoTime() and System.currentTimeMillis() under the covers.
    • A user can supply their own NatsSystemClockProvider. For example, for an Android add, the developer could wrap the Android SystemClock.
  • Replaced System.currentTimeMillis() usages with NatsSystemClock.nanoTime() to ensure proper elapsed time in general
  • Replaced all usage of System.nanoTime() with NatsSystemClock.nanoTime()

This PR is addresing #1331 and #1332. To Do (Another PR) - Replaced Task/Timers with timers using the NatsSystemClock

@scottf scottf changed the title Use nano time for elapsed timings Nano time for elapsed timings and Nats System Clock Jun 19, 2025
@scottf scottf requested a review from MauriceVanVeen June 19, 2025 21:29
Copy link
Member

@MauriceVanVeen MauriceVanVeen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@scottf scottf merged commit 5fb9f42 into main Jun 20, 2025
5 checks passed
@scottf scottf deleted the timers-move-to-nano branch June 20, 2025 12:27
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.

2 participants