1
0
mirror of https://github.com/golang/go synced 2024-11-18 16:14:46 -07:00

runtime: convert local var ready at TestMemmoveAtomicity to atomic type

For #53821

Change-Id: I2487b8d18a4cd3fc6e64fbbb531419812bfe0f08
Reviewed-on: https://go-review.googlesource.com/c/go/+/427136
Run-TryBot: xie cui <523516579@qq.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
This commit is contained in:
cuiweixie 2022-09-02 10:31:34 +08:00 committed by Daniel Martí
parent 357b922517
commit 7d83d320c0

View File

@ -244,23 +244,23 @@ func TestMemmoveAtomicity(t *testing.T) {
dst[i] = nil dst[i] = nil
} }
var ready uint32 var ready atomic.Uint32
go func() { go func() {
sp := unsafe.Pointer(&src[0]) sp := unsafe.Pointer(&src[0])
dp := unsafe.Pointer(&dst[0]) dp := unsafe.Pointer(&dst[0])
atomic.StoreUint32(&ready, 1) ready.Store(1)
for i := 0; i < 10000; i++ { for i := 0; i < 10000; i++ {
Memmove(dp, sp, sz) Memmove(dp, sp, sz)
MemclrNoHeapPointers(dp, sz) MemclrNoHeapPointers(dp, sz)
} }
atomic.StoreUint32(&ready, 2) ready.Store(2)
}() }()
for atomic.LoadUint32(&ready) == 0 { for ready.Load() == 0 {
Gosched() Gosched()
} }
for atomic.LoadUint32(&ready) != 2 { for ready.Load() != 2 {
for i := range dst { for i := range dst {
p := dst[i] p := dst[i]
if p != nil && p != &x { if p != nil && p != &x {