From 014f0e8205aa5d88a0dc1be75ec09a18132b216c Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Wed, 17 Aug 2022 14:34:46 +0700 Subject: [PATCH] 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 --- src/runtime/mheap.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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. -- 2.50.0