(t *testing.T)
| 27 | } |
| 28 | |
| 29 | func TestMutexMap_SharedLock(t *testing.T) { |
| 30 | var m mutexMap |
| 31 | |
| 32 | require.Empty(t, m.entries) |
| 33 | m.sharedLock("foo") |
| 34 | require.Len(t, m.entries, 1) |
| 35 | m.sharedLock("foo") |
| 36 | require.Len(t, m.entries, 1) |
| 37 | require.True(t, m.trySharedLock("foo")) |
| 38 | require.Len(t, m.entries, 1) |
| 39 | |
| 40 | // exclusive lock can't be acquired while shared lock is held |
| 41 | require.False(t, m.tryExclusiveLock("foo")) |
| 42 | m.sharedUnlock("foo") |
| 43 | require.False(t, m.tryExclusiveLock("foo")) |
| 44 | m.sharedUnlock("foo") |
| 45 | require.False(t, m.tryExclusiveLock("foo")) |
| 46 | m.sharedUnlock("foo") |
| 47 | |
| 48 | // now exclusive lock can be acquired |
| 49 | require.True(t, m.tryExclusiveLock("foo")) |
| 50 | } |
nothing calls this directly
no test coverage detected