MCPcopy Index your code
hub / github.com/cortexproject/cortex / StopAndDrainTimer

Function StopAndDrainTimer

pkg/util/timer/timer.go:6–17  ·  view source on GitHub ↗

StopAndDrainTimer stops the timer and drains its channel if a tick was already queued.

(timer *time.Timer)

Source from the content-addressed store, hash-verified

4
5// StopAndDrainTimer stops the timer and drains its channel if a tick was already queued.
6func StopAndDrainTimer(timer *time.Timer) {
7 if timer == nil {
8 return
9 }
10
11 if !timer.Stop() {
12 select {
13 case <-timer.C:
14 default:
15 }
16 }
17}
18
19// ResetTimer safely resets timer, handling the required stop+drain sequence first.
20func ResetTimer(timer *time.Timer, d time.Duration) {

Callers 4

ResetTimerFunction · 0.85

Calls 1

StopMethod · 0.65