newDisableableTicker essentially wraps NewTicker but allows the ticker to be disabled by passing zero duration as the interval. Returns a function for stopping the ticker, and the ticker channel.
(interval time.Duration)
| 5 | // newDisableableTicker essentially wraps NewTicker but allows the ticker to be disabled by passing |
| 6 | // zero duration as the interval. Returns a function for stopping the ticker, and the ticker channel. |
| 7 | func newDisableableTicker(interval time.Duration) (func(), <-chan time.Time) { |
| 8 | if interval == 0 { |
| 9 | return func() {}, nil |
| 10 | } |
| 11 | |
| 12 | tick := time.NewTicker(interval) |
| 13 | return func() { tick.Stop() }, tick.C |
| 14 | } |