Skip to content

Commit 7c911a8

Browse files
authored
Protect advanceable.now field (#8)
1 parent 310f6fc commit 7c911a8

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

mock_timer.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,14 @@ func newMockTimerAt(
5555
panic("duration cannot be 0")
5656
}
5757

58+
advanceable.m.Lock()
5859
t := &MockTimer{
5960
advanceable: advanceable,
6061
deadline: advanceable.now.Add(duration),
6162
ch: make(chan time.Time),
6263
f: f,
6364
}
65+
advanceable.m.Unlock()
6466

6567
go t.process()
6668
advanceable.register(t)

0 commit comments

Comments
 (0)