1
0
mirror of https://github.com/golang/go synced 2024-11-22 22:50:03 -07:00

runtime: convert mSpanStateBox.s to atomic type

Updates #53821

Change-Id: I02f31a7a8295deb3e840565412abf10ff776c2c3
Reviewed-on: https://go-review.googlesource.com/c/go/+/424395
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Keith Randall <khr@google.com>
This commit is contained in:
Cuong Manh Le 2022-08-17 14:34:46 +07:00 committed by Gopher Robot
parent 5b0ce94c07
commit 014f0e8205

View File

@ -363,19 +363,19 @@ var mSpanStateNames = []string{
"mSpanFree",
}
// mSpanStateBox holds an mSpanState and provides atomic operations on
// it. This is a separate type to disallow accidental comparison or
// assignment with mSpanState.
// mSpanStateBox holds an atomic.Uint8 to provide atomic operations on
// an mSpanState. This is a separate type to disallow accidental comparison
// or assignment with mSpanState.
type mSpanStateBox struct {
s mSpanState
s atomic.Uint8
}
func (b *mSpanStateBox) set(s mSpanState) {
atomic.Store8((*uint8)(&b.s), uint8(s))
b.s.Store(uint8(s))
}
func (b *mSpanStateBox) get() mSpanState {
return mSpanState(atomic.Load8((*uint8)(&b.s)))
return mSpanState(b.s.Load())
}
// mSpanList heads a linked list of spans.