Browse Source

Merge pull request #151 from tendermint/fix/nit

minor nit
pull/1842/head
Ethan Buchman 7 years ago
committed by GitHub
parent
commit
a0f652dc2e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 5 deletions
  1. +8
    -5
      common/repeat_timer.go

+ 8
- 5
common/repeat_timer.go View File

@ -20,15 +20,17 @@ type Ticker interface {
} }
//---------------------------------------- //----------------------------------------
// defaultTickerMaker
// defaultTicker
var _ Ticker = (*defaultTicker)(nil)
type defaultTicker time.Ticker
func defaultTickerMaker(dur time.Duration) Ticker { func defaultTickerMaker(dur time.Duration) Ticker {
ticker := time.NewTicker(dur) ticker := time.NewTicker(dur)
return (*defaultTicker)(ticker) return (*defaultTicker)(ticker)
} }
type defaultTicker time.Ticker
// Implements Ticker // Implements Ticker
func (t *defaultTicker) Chan() <-chan time.Time { func (t *defaultTicker) Chan() <-chan time.Time {
return t.C return t.C
@ -151,12 +153,13 @@ func NewRepeatTimerWithTickerMaker(name string, dur time.Duration, tm TickerMake
return t return t
} }
// receive ticks on ch, send out on t.ch
func (t *RepeatTimer) fireRoutine(ch <-chan time.Time, quit <-chan struct{}) { func (t *RepeatTimer) fireRoutine(ch <-chan time.Time, quit <-chan struct{}) {
for { for {
select { select {
case t_ := <-ch:
case tick := <-ch:
select { select {
case t.ch <- t_:
case t.ch <- tick:
case <-quit: case <-quit:
return return
} }


Loading…
Cancel
Save