Fix rwmutex test
This commit is contained in:
parent
b47acc1e28
commit
91fdec209b
1 changed files with 2 additions and 2 deletions
|
@ -5,6 +5,7 @@ import (
|
||||||
"runtime"
|
"runtime"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func parallelReader(m *RWMutex, clocked, cunlock, cdone chan bool) {
|
func parallelReader(m *RWMutex, clocked, cunlock, cdone chan bool) {
|
||||||
|
@ -98,7 +99,6 @@ func HammerRWMutex(gomaxprocs, numReaders, numIterations int) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRWMutexReadWrite(t *testing.T) {
|
func TestRWMutexReadWrite(t *testing.T) {
|
||||||
timeout := time.After(5 * time.Second)
|
|
||||||
done := make(chan bool)
|
done := make(chan bool)
|
||||||
go func() {
|
go func() {
|
||||||
rwm := New()
|
rwm := New()
|
||||||
|
@ -108,7 +108,7 @@ func TestRWMutexReadWrite(t *testing.T) {
|
||||||
}()
|
}()
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case <-timeout:
|
case <-time.After(time.Second):
|
||||||
case <-done:
|
case <-done:
|
||||||
t.Fatal("Test finished, must be deadlock")
|
t.Fatal("Test finished, must be deadlock")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue