diff options
author | Ian Gudger <igudger@google.com> | 2020-01-21 19:23:26 -0800 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-01-21 19:36:12 -0800 |
commit | 6a59e7f510a7b12f8b3bd768dfe569033ef07d30 (patch) | |
tree | f3230ab8459461bff3449db656aa9ccff1a7af5e /pkg/sync/downgradable_rwmutex_test.go | |
parent | d0e75f2bef4e16356693987db6ae6bbdce749618 (diff) |
Rename DowngradableRWMutex to RWmutex.
Also renames TMutex to Mutex.
These custom mutexes aren't any worse than the standard library versions (same
code), so having both seems redundant.
PiperOrigin-RevId: 290873587
Diffstat (limited to 'pkg/sync/downgradable_rwmutex_test.go')
-rw-r--r-- | pkg/sync/downgradable_rwmutex_test.go | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/pkg/sync/downgradable_rwmutex_test.go b/pkg/sync/downgradable_rwmutex_test.go index b5cb28ec0..ce667e825 100644 --- a/pkg/sync/downgradable_rwmutex_test.go +++ b/pkg/sync/downgradable_rwmutex_test.go @@ -18,7 +18,7 @@ import ( "testing" ) -func parallelReader(m *DowngradableRWMutex, clocked, cunlock, cdone chan bool) { +func parallelReader(m *RWMutex, clocked, cunlock, cdone chan bool) { m.RLock() clocked <- true <-cunlock @@ -28,7 +28,7 @@ func parallelReader(m *DowngradableRWMutex, clocked, cunlock, cdone chan bool) { func doTestParallelReaders(numReaders, gomaxprocs int) { runtime.GOMAXPROCS(gomaxprocs) - var m DowngradableRWMutex + var m RWMutex clocked := make(chan bool) cunlock := make(chan bool) cdone := make(chan bool) @@ -55,7 +55,7 @@ func TestParallelReaders(t *testing.T) { doTestParallelReaders(4, 2) } -func reader(rwm *DowngradableRWMutex, numIterations int, activity *int32, cdone chan bool) { +func reader(rwm *RWMutex, numIterations int, activity *int32, cdone chan bool) { for i := 0; i < numIterations; i++ { rwm.RLock() n := atomic.AddInt32(activity, 1) @@ -70,7 +70,7 @@ func reader(rwm *DowngradableRWMutex, numIterations int, activity *int32, cdone cdone <- true } -func writer(rwm *DowngradableRWMutex, numIterations int, activity *int32, cdone chan bool) { +func writer(rwm *RWMutex, numIterations int, activity *int32, cdone chan bool) { for i := 0; i < numIterations; i++ { rwm.Lock() n := atomic.AddInt32(activity, 10000) @@ -85,7 +85,7 @@ func writer(rwm *DowngradableRWMutex, numIterations int, activity *int32, cdone cdone <- true } -func downgradingWriter(rwm *DowngradableRWMutex, numIterations int, activity *int32, cdone chan bool) { +func downgradingWriter(rwm *RWMutex, numIterations int, activity *int32, cdone chan bool) { for i := 0; i < numIterations; i++ { rwm.Lock() n := atomic.AddInt32(activity, 10000) @@ -112,7 +112,7 @@ func HammerDowngradableRWMutex(gomaxprocs, numReaders, numIterations int) { runtime.GOMAXPROCS(gomaxprocs) // Number of active readers + 10000 * number of active writers. var activity int32 - var rwm DowngradableRWMutex + var rwm RWMutex cdone := make(chan bool) go writer(&rwm, numIterations, &activity, cdone) go downgradingWriter(&rwm, numIterations, &activity, cdone) @@ -150,56 +150,56 @@ func TestDowngradableRWMutex(t *testing.T) { } func TestRWDoubleTryLock(t *testing.T) { - var m DowngradableRWMutex - if !m.TryLock() { + var rwm RWMutex + if !rwm.TryLock() { t.Fatal("failed to aquire lock") } - if m.TryLock() { + if rwm.TryLock() { t.Fatal("unexpectedly succeeded in aquiring locked mutex") } } func TestRWTryLockAfterLock(t *testing.T) { - var m DowngradableRWMutex - m.Lock() - if m.TryLock() { + var rwm RWMutex + rwm.Lock() + if rwm.TryLock() { t.Fatal("unexpectedly succeeded in aquiring locked mutex") } } func TestRWTryLockUnlock(t *testing.T) { - var m DowngradableRWMutex - if !m.TryLock() { + var rwm RWMutex + if !rwm.TryLock() { t.Fatal("failed to aquire lock") } - m.Unlock() - if !m.TryLock() { + rwm.Unlock() + if !rwm.TryLock() { t.Fatal("failed to aquire lock after unlock") } } func TestTryRLockAfterLock(t *testing.T) { - var m DowngradableRWMutex - m.Lock() - if m.TryRLock() { + var rwm RWMutex + rwm.Lock() + if rwm.TryRLock() { t.Fatal("unexpectedly succeeded in aquiring locked mutex") } } func TestTryLockAfterRLock(t *testing.T) { - var m DowngradableRWMutex - m.RLock() - if m.TryLock() { + var rwm RWMutex + rwm.RLock() + if rwm.TryLock() { t.Fatal("unexpectedly succeeded in aquiring locked mutex") } } func TestDoubleTryRLock(t *testing.T) { - var m DowngradableRWMutex - if !m.TryRLock() { + var rwm RWMutex + if !rwm.TryRLock() { t.Fatal("failed to aquire lock") } - if !m.TryRLock() { + if !rwm.TryRLock() { t.Fatal("failed to read aquire read locked lock") } } |