mirror of
https://github.com/hanzoai/traces.git
synced 2026-10-30 18:20:41 +00:00
15 lines
433 B
Go
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
|
|
}
|