Skip to content

Commit

Permalink
runtime: convert local var stop at TestAfterStress to atomic type
Browse files Browse the repository at this point in the history
For golang#53821

Change-Id: I7e86dac34691f7752f68879ff379061f3435cd45
  • Loading branch information
cuiweixie committed Sep 2, 2022
1 parent b9a8021 commit c8cacc4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/time/sleep_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)) {
Expand Down

0 comments on commit c8cacc4

Please sign in to comment.