]> Cypherpunks.ru repositories - gostls13.git/commitdiff
runtime: convert local var stop at TestAfterStress to atomic type
authorcuiweixie <cuiweixie@gmail.com>
Fri, 2 Sep 2022 02:53:13 +0000 (10:53 +0800)
committerDaniel Martí <mvdan@mvdan.cc>
Mon, 5 Sep 2022 08:08:24 +0000 (08:08 +0000)
For #53821

Change-Id: I7e86dac34691f7752f68879ff379061f3435cd45
Reviewed-on: https://go-review.googlesource.com/c/go/+/427139
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: xie cui <523516579@qq.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
src/time/sleep_test.go

index 5a949b6f80e943150e09c966ef6df75017baa72c..8aac3b68f674d614480a04b187e1515403b8295e 100644 (file)
@@ -65,9 +65,9 @@ func TestAfterFunc(t *testing.T) {
 }
 
 func TestAfterStress(t *testing.T) {
-       stop := uint32(0)
+       var stop atomic.Bool
        go func() {
-               for atomic.LoadUint32(&stop) == 0 {
+               for !stop.Load() {
                        runtime.GC()
                        // Yield so that the OS can wake up the timer thread,
                        // so that it can generate channel sends for the main goroutine,
@@ -80,7 +80,7 @@ func TestAfterStress(t *testing.T) {
                <-ticker.C
        }
        ticker.Stop()
-       atomic.StoreUint32(&stop, 1)
+       stop.Store(true)
 }
 
 func benchmark(b *testing.B, bench func(n int)) {