mirror of https://github.com/golang/go.git
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:
parent
5b0ce94c07
commit
014f0e8205
|
|
@ -363,19 +363,19 @@ var mSpanStateNames = []string{
|
||||||
"mSpanFree",
|
"mSpanFree",
|
||||||
}
|
}
|
||||||
|
|
||||||
// mSpanStateBox holds an mSpanState and provides atomic operations on
|
// mSpanStateBox holds an atomic.Uint8 to provide atomic operations on
|
||||||
// it. This is a separate type to disallow accidental comparison or
|
// an mSpanState. This is a separate type to disallow accidental comparison
|
||||||
// assignment with mSpanState.
|
// or assignment with mSpanState.
|
||||||
type mSpanStateBox struct {
|
type mSpanStateBox struct {
|
||||||
s mSpanState
|
s atomic.Uint8
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *mSpanStateBox) set(s mSpanState) {
|
func (b *mSpanStateBox) set(s mSpanState) {
|
||||||
atomic.Store8((*uint8)(&b.s), uint8(s))
|
b.s.Store(uint8(s))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *mSpanStateBox) get() mSpanState {
|
func (b *mSpanStateBox) get() mSpanState {
|
||||||
return mSpanState(atomic.Load8((*uint8)(&b.s)))
|
return mSpanState(b.s.Load())
|
||||||
}
|
}
|
||||||
|
|
||||||
// mSpanList heads a linked list of spans.
|
// mSpanList heads a linked list of spans.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue