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

Function delTimerLocked

timers.go:51–71  ·  view source on GitHub ↗

Delete timer t from the heap. It returns true if t was removed, false if t wasn't even there. Do not need to update the timer routine: if it wakes up early, no big deal.

(t *Timer)

Source from the content-addressed store, hash-verified

49// It returns true if t was removed, false if t wasn't even there.
50// Do not need to update the timer routine: if it wakes up early, no big deal.
51func delTimerLocked(t *Timer) bool {
52 // t may not be registered anymore and may have
53 // a bogus i (typically 0, if generated by Go).
54 // Verify it before proceeding.
55 i := t.i
56 last := len(timers) - 1
57 if i < 0 || i > last || timers[i] != t {
58 return false
59 }
60 if i != last {
61 timers[i] = timers[last]
62 timers[i].i = i
63 }
64 timers[last] = nil
65 timers = timers[:last]
66 if i != last {
67 siftupTimer(i)
68 siftdownTimer(i)
69 }
70 return true
71}
72
73// Reset the timer to the new timeout duration.
74// This clears the channel.

Callers 2

delTimerFunction · 0.85
resetTimerFunction · 0.85

Calls 2

siftupTimerFunction · 0.85
siftdownTimerFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…