little things

This commit is contained in:
Ethan Buchman 2017-12-25 10:13:37 -05:00
parent 6b5d08f7da
commit 76433d9040
2 changed files with 6 additions and 7 deletions

View File

@ -42,11 +42,11 @@ func (t *defaultTicker) Stop() {
//----------------------------------------
// LogicalTickerMaker
// Construct a TickerMaker that always uses `ch`.
// Construct a TickerMaker that always uses `source`.
// It's useful for simulating a deterministic clock.
func NewLogicalTickerMaker(ch chan time.Time) TickerMaker {
func NewLogicalTickerMaker(source chan time.Time) TickerMaker {
return func(dur time.Duration) Ticker {
return newLogicalTicker(ch, dur)
return newLogicalTicker(source, dur)
}
}
@ -66,8 +66,8 @@ func newLogicalTicker(source <-chan time.Time, interval time.Duration) Ticker {
return lt
}
// We clearly need a new goroutine, for logicalTicker may have been created
// from a goroutine separate from the source.
// We need a goroutine to read times from t.source
// and fire on t.Chan() when `interval` has passed.
func (t *logicalTicker) fireRoutine(interval time.Duration) {
source := t.source

View File

@ -29,7 +29,6 @@ func TestRepeat(t *testing.T) {
select {
case _ = <-rt.Chan():
case <-timeout:
panic("QWE")
t.Fatal("expected RepeatTimer to fire")
}
}
@ -43,7 +42,7 @@ func TestRepeat(t *testing.T) {
}
tm := NewLogicalTickerMaker(ch)
dur := time.Duration(0) // dontcare
dur := time.Duration(10 * time.Millisecond) // less than a second
rt := NewRepeatTimerWithTickerMaker("bar", dur, tm)
// Start at 0.