mirror of
https://gitee.com/johng/gf.git
synced 2024-12-03 04:37:49 +08:00
Improve gflock unit testing.
This commit is contained in:
parent
0f14002b05
commit
3806f9db07
@ -79,20 +79,20 @@ func Test_GFlock_RLock(t *testing.T) {
|
||||
go func() {
|
||||
lock.RLock()
|
||||
array.Append(1)
|
||||
time.Sleep(200 * time.Millisecond)
|
||||
time.Sleep(400 * time.Millisecond)
|
||||
lock.RUnlock()
|
||||
}()
|
||||
|
||||
go func() {
|
||||
time.Sleep(50 * time.Millisecond)
|
||||
time.Sleep(200 * time.Millisecond)
|
||||
lock2.RLock()
|
||||
array.Append(1)
|
||||
lock2.RUnlock()
|
||||
}()
|
||||
|
||||
time.Sleep(50 * time.Millisecond)
|
||||
gtest.Assert(array.Len(), 1)
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
gtest.Assert(array.Len(), 1)
|
||||
time.Sleep(200 * time.Millisecond)
|
||||
gtest.Assert(array.Len(), 2)
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user