AtomicCounter release/acquire methods#315
Merged
vyazelenko merged 6 commits intoFeb 1, 2025
Merged
Conversation
60fde98 to
a8cce93
Compare
pveentjer
commented
Jan 20, 2025
| } | ||
|
|
||
| /** | ||
| * Get the latest value for the counter with volatile semantics. |
Contributor
Author
There was a problem hiding this comment.
I have removed 'latest' because it implies that you will see the latest value. This isn't true. A correctly synchronized program will only show sequential consistent executions, and for sequential consistency, the real time order doesn't need to respected. For that you need linearizability.
The JVM will guarantee visibility, so it will promise that a value is seen eventually (but not immediately).
Unfortunately 'latest' is frequently mentioned even by JMM experts, but it isn't correct.
To make this PR less contentious.
vyazelenko
requested changes
Jan 31, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For all ordered methods, there is now a release variant. The ordered method will call the release version, so there is a slight performance penalty to pay.
Also getAcquire has been added since that normally is used in combination with a release method.