MCPcopy
hub / github.com/grafana/dskit / newDisableableTicker

Function newDisableableTicker

ring/ticker.go:7–14  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
7func 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}

Callers 7

loopMethod · 0.85
stoppingMethod · 0.85
runningMethod · 0.85
stoppingMethod · 0.85
waitStableTokensMethod · 0.85

Calls 1

StopMethod · 0.65