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

Pull-fetch-time-left #879

Merged
merged 2 commits into from
Apr 6, 2023
Merged

Pull-fetch-time-left #879

merged 2 commits into from
Apr 6, 2023

Conversation

liu-jianyang
Copy link
Contributor

Update to use System.nanoTime() instead of System.currentTimeMillis() to move away from wall clock.

@liu-jianyang liu-jianyang marked this pull request as draft April 5, 2023 19:39
@liu-jianyang liu-jianyang marked this pull request as ready for review April 5, 2023 19:45
@liu-jianyang liu-jianyang requested a review from scottf April 6, 2023 14:41
Copy link
Contributor

@scottf scottf 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 9f9edfe into nats-io:main Apr 6, 2023
while (batchLeft > 0 && timeLeft > 0) {
Message msg = nextMessageInternal( Duration.ofMillis(timeLeft) );
long maxWaitNanos = maxWaitMillis * 1_000_000;
long timeLeftNanos = maxWaitNanos;
Copy link

Choose a reason for hiding this comment

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

Shouldn't timeLeftNanos be initialized to maxWaitNanos - (System.nanoTime() - start) as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the reasoning here is that we want to at least allow processing a single message to send back, which could no longer be the case if timeLeftNanos is set to maxWaitNanos - (System.nanoTime() - start) since we could set maxWaitNanos really small.

@liu-jianyang liu-jianyang deleted the pull-fetch-time-left branch April 6, 2023 17:37
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.

None yet

3 participants