cleanup: Use Go 1.19 atomic types#5792
Merged
algorandskiy merged 4 commits intoalgorand:masterfrom Oct 23, 2023
Merged
Conversation
sed -E -i -e 's/atomic.Load(Int32|Uint64|Uint32|Int64)\(&([^\)]+)\)/\2.Load()/g' \
-e 's/atomic.Store(Int32|Uint64|Uint32|Int64)\(&([^,]+), ([^,]+)\)/\2.Store(\3)/g' \
-e 's/atomic.CompareAndSwap(Int32|Uint64|Uint32|Int64)\(&([^,]+), ([^,]+), ([^,]+)\)/\2.CompareAndSwap(\3, \4)/g' \
-e 's/atomic.Add(Int32|Uint64|Uint32|Int64)\(&([^,]+), ([^,]+)\)/\2.Add(\3)/g' *.go
Codecov Report
@@ Coverage Diff @@
## master #5792 +/- ##
==========================================
- Coverage 55.55% 55.54% -0.01%
==========================================
Files 474 474
Lines 66850 66848 -2
==========================================
- Hits 37138 37133 -5
- Misses 27188 27190 +2
- Partials 2524 2525 +1
... and 13 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
jasonpaulos
reviewed
Oct 20, 2023
Contributor
algorandskiy
left a comment
There was a problem hiding this comment.
Basically the same questions as Jason had
jasonpaulos
approved these changes
Oct 20, 2023
cce
approved these changes
Oct 20, 2023
Contributor
cce
left a comment
There was a problem hiding this comment.
Seems to have possibly fixed some bugs with handling of atomics
algorandskiy
approved these changes
Oct 21, 2023
This was referenced Nov 16, 2023
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.
Summary
Go 1.19 introduced types like atomic.Uint64, atomic.Int32, atomic.Bool, that provide automatic alignment for 32-bit platforms, plus extra safety to ensure access to the underlying value only uses atomic methods. This converts nearly all the calls to atomic to use these types. It also catches a few places where non-atomic and atomic access were mixed together.
Test Plan
Removed TestAtomicVariablesAlignment