MCPcopy Create free account
hub / github.com/desertbit/timer / siftdownTimer

Function siftdownTimer

timers.go:180–215  ·  view source on GitHub ↗
(i int)

Source from the content-addressed store, hash-verified

178}
179
180func siftdownTimer(i int) {
181 n := len(timers)
182 when := timers[i].when
183 tmp := timers[i]
184 for {
185 c := i*4 + 1 // left child
186 c3 := c + 2 // mid child
187 if c >= n {
188 break
189 }
190 w := timers[c].when
191 if c+1 < n && timers[c+1].when.Before(w) {
192 w = timers[c+1].when
193 c++
194 }
195 if c3 < n {
196 w3 := timers[c3].when
197 if c3+1 < n && timers[c3+1].when.Before(w3) {
198 w3 = timers[c3+1].when
199 c3++
200 }
201 if w3.Before(w) {
202 w = w3
203 c = c3
204 }
205 }
206 if !w.Before(when) {
207 break
208 }
209 timers[i] = timers[c]
210 timers[i].i = i
211 timers[c] = tmp
212 timers[c].i = c
213 i = c
214 }
215}

Callers 2

delTimerLockedFunction · 0.85
timerRoutineFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…