-
Notifications
You must be signed in to change notification settings - Fork 493
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
cleanup: Use Go 1.19 atomic types #5792
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 |
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.
Basically the same questions as Jason had
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.
Seems to have possibly fixed some bugs with handling of atomics
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