Files

15 lines
433 B
Go

package ring
import "time"
// 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.
func newDisableableTicker(interval time.Duration) (func(), <-chan time.Time) {
if interval == 0 {
return func() {}, nil
}
tick := time.NewTicker(interval)
return func() { tick.Stop() }, tick.C
}