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)
| 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. |
| 51 | func 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. |
no test coverage detected
searching dependent graphs…