From: Cuong Manh Le Date: Wed, 17 Aug 2022 07:34:46 +0000 (+0700) Subject: runtime: convert mSpanStateBox.s to atomic type X-Git-Tag: go1.20rc1~1595 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=014f0e8205aa5d88a0dc1be75ec09a18132b216c;p=gostls13.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 Auto-Submit: Cuong Manh Le TryBot-Result: Gopher Robot Reviewed-by: Michael Pratt Reviewed-by: Keith Randall --- diff --git a/src/runtime/mheap.go b/src/runtime/mheap.go index 12307594f0..00d445c1fa 100644 --- a/src/runtime/mheap.go +++ b/src/runtime/mheap.go @@ -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.