MCPcopy
hub / github.com/grpc/grpc-go / TrackTimers

Function TrackTimers

internal/leakcheck/leakcheck.go:333–338  ·  view source on GitHub ↗

TrackTimers replaces internal.TimerAfterFunc with one that tracks timer creations, stoppages and expirations. CheckTimers should then be invoked at the end of the test to validate that all timers created have either executed or are cancelled.

()

Source from the content-addressed store, hash-verified

331// the end of the test to validate that all timers created have either executed
332// or are cancelled.
333func TrackTimers() {
334 globalTimerTracker = &timerFactory{
335 allocatedTimers: make(map[internal.Timer][]uintptr),
336 }
337 internal.TimeAfterFunc = globalTimerTracker.timeAfterFunc
338}
339
340// CheckTimers undoes the effects of TrackTimers, and fails unit tests if not
341// all timers were cancelled or executed. It is invalid to invoke this function

Callers 2

SetupMethod · 0.92
TestTrackTimersFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestTrackTimersFunction · 0.68