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

Method TestWriterTimeout

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

Source from the content-addressed store, hash-verified

20var _ = Suite(&BoundedRWLockSuite{})
21
22func (suite *BoundedRWLockSuite) TestWriterTimeout(t *C) {
23 clocked := make(chan bool)
24 cunlock := make(chan bool)
25 cunlocked := make(chan bool)
26 var rwl *BoundedRWLock = NewBoundedRWLock(100)
27 go func() {
28 if err := rwl.RLock(100 * time.Millisecond); err != nil {
29 panic(fmt.Sprintf("contention??"))
30 }
31
32 clocked <- true
33 <-cunlock
34 rwl.RUnlock()
35 cunlocked <- true
36 }()
37
38 <-clocked
39 begin := time.Now()
40 err := rwl.WLock(100 * time.Millisecond)
41 t.Assert(err, NotNil)
42 t.Assert(time.Now().Sub(begin) >= 100*time.Millisecond, Equals, true)
43
44 cunlock <- true
45 <-cunlocked
46 err = rwl.WLock(100 * time.Millisecond)
47 t.Assert(err, IsNil)
48 rwl.WUnlock()
49}
50
51func (suite *BoundedRWLockSuite) TestReaderTimeout(t *C) {
52 clocked := make(chan bool)

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected