-
Notifications
You must be signed in to change notification settings - Fork 426
OAK-12037 : remove usage of Guava's Monitor from oak-lucene #2660
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
base: trunk
Are you sure you want to change the base?
Conversation
|
| // timeout | ||
| break; | ||
| } | ||
| notCopyingCondition.awaitNanos(remaining); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This whole nano calculation seems clumsy. Why not just notCopyingCondition.await(timeoutMillis, TimeUnit.MILLISECONDS) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK the thread could be woken up in some cases, and so a loop is needed, and so a calculation is needed.
| boolean notCopying = !isCopyInProgress(file); | ||
| while (!notCopying) { | ||
| final long deadline = System.nanoTime() + TimeUnit.MILLISECONDS.toNanos(timeoutMillis); | ||
| copyCompletionLock.lock(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is that working with the timeout?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
by following this logic, we ensure that we block for only an absolute time in future.
On each inner-loop iteration you recompute remaining = deadline - System.nanoTime()
This is to ensure that regardless of how many times the threads are woken, we only wait for timeoutMillis.
mbaedke
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comments inline.




No description provided.