MCPcopy
hub / github.com/dropbox/godropbox / TestReaderTimeout

Method TestReaderTimeout

sync2/boundedrwlock_test.go:51–78  ·  view source on GitHub ↗
(t *C)

Source from the content-addressed store, hash-verified

49}
50
51func (suite *BoundedRWLockSuite) TestReaderTimeout(t *C) {
52 clocked := make(chan bool)
53 cunlock := make(chan bool)
54 cunlocked := make(chan bool)
55 var rwl *BoundedRWLock = NewBoundedRWLock(100)
56 go func() {
57 if err := rwl.WLock(100 * time.Millisecond); err != nil {
58 panic(fmt.Sprintf("contention??"))
59 }
60
61 clocked <- true
62 <-cunlock
63 rwl.WUnlock()
64 cunlocked <- true
65 }()
66
67 <-clocked
68 begin := time.Now()
69 err := rwl.RLock(100 * time.Millisecond)
70 t.Assert(err, NotNil)
71 t.Assert(time.Now().Sub(begin) >= 100*time.Millisecond, Equals, true)
72
73 cunlock <- true
74 <-cunlocked
75 err = rwl.RLock(100 * time.Millisecond)
76 t.Assert(err, IsNil)
77 rwl.RUnlock()
78}
79
80func doTestParallelReaders(gomaxprocs, numReaders int) {
81 runtime.GOMAXPROCS(gomaxprocs)

Callers

nothing calls this directly

Calls 7

WLockMethod · 0.95
WUnlockMethod · 0.95
RLockMethod · 0.95
RUnlockMethod · 0.95
NewBoundedRWLockFunction · 0.85
NowMethod · 0.65
SubMethod · 0.65

Tested by

no test coverage detected