MCPcopy Create free account
hub / github.com/tailscale/tailscale / Reschedule

Method Reschedule

tstest/clock.go:415–445  ·  view source on GitHub ↗

Reschedule adds/updates/deletes an event in the heap, whichever operation is applicable (use a zero time to delete).

(eh eventHandler, t time.Time)

Source from the content-addressed store, hash-verified

413// Reschedule adds/updates/deletes an event in the heap, whichever
414// operation is applicable (use a zero time to delete).
415func (em *eventManager) Reschedule(eh eventHandler, t time.Time) {
416 em.mu.Lock()
417 defer em.mu.Unlock()
418 defer em.updateTimerLocked()
419
420 e, ok := em.reverseLookup[eh]
421 if !ok {
422 if t.IsZero() {
423 // eh is not scheduled and also not active, so do nothing.
424 return
425 }
426 // eh is not scheduled but is active, so add it.
427 heap.Push(em, &event{
428 when: t,
429 eh: eh,
430 })
431 em.processEventsLocked(em.now) // This is always safe and required when !t.After(em.now).
432 return
433 }
434
435 if t.IsZero() {
436 // e is scheduled but not active, so remove it.
437 heap.Remove(em, e.position)
438 return
439 }
440
441 // e is scheduled and active, so update it.
442 e.when = t
443 heap.Fix(em, e.position)
444 em.processEventsLocked(em.now) // This is always safe and required when !t.After(em.now).
445}
446
447// AdvanceTo updates the current time to tm and fires all events scheduled
448// before or equal to tm. When an event fires, it may request rescheduling and

Callers 7

TestEventManagerFunction · 0.95
initMethod · 0.80
ResetMethod · 0.80
ResetAbsoluteMethod · 0.80
StopMethod · 0.80
initMethod · 0.80
resetMethod · 0.80

Calls 7

updateTimerLockedMethod · 0.95
processEventsLockedMethod · 0.95
LockMethod · 0.65
UnlockMethod · 0.65
IsZeroMethod · 0.65
PushMethod · 0.65
RemoveMethod · 0.65

Tested by 1

TestEventManagerFunction · 0.76