1
0
mirror of https://github.com/golang/go synced 2024-11-23 19:50:06 -07:00

runtime: fix data race in BenchmarkChanPopular

Fixes #11014.

Change-Id: I9a18dacd10564d3eaa1fea4d77f1a48e08e79f53
Reviewed-on: https://go-review.googlesource.com/10563
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
Mikio Hara 2015-06-01 13:25:03 +09:00
parent 71cc675572
commit 1fa0a8cec5

View File

@ -898,6 +898,8 @@ func BenchmarkChanPopular(b *testing.B) {
const n = 1000
c := make(chan bool)
var a []chan bool
var wg sync.WaitGroup
wg.Add(n)
for j := 0; j < n; j++ {
d := make(chan bool)
a = append(a, d)
@ -908,6 +910,7 @@ func BenchmarkChanPopular(b *testing.B) {
case <-d:
}
}
wg.Done()
}()
}
for i := 0; i < b.N; i++ {
@ -915,4 +918,5 @@ func BenchmarkChanPopular(b *testing.B) {
d <- true
}
}
wg.Wait()
}