Implement null timer

NullClock.AfterFunc should not return nil as that violates the API
expectations. Instead, return a timer that never fires.

PiperOrigin-RevId: 500240130
This commit is contained in:
Ghanan Gowripalan
2023-01-06 15:27:20 -08:00
committed by gVisor bot
parent 3cbd2127f0
commit 3d4743d960
+14 -1
View File
@@ -39,9 +39,22 @@ func (*NullClock) NowMonotonic() tcpip.MonotonicTime {
return tcpip.MonotonicTime{}
}
// nullTimer implements a timer that never fires.
type nullTimer struct{}
var _ tcpip.Timer = (*nullTimer)(nil)
// Stop implements tcpip.Timer.
func (*nullTimer) Stop() bool {
return true
}
// Reset implements tcpip.Timer.
func (*nullTimer) Reset(time.Duration) {}
// AfterFunc implements tcpip.Clock.AfterFunc.
func (*NullClock) AfterFunc(time.Duration, func()) tcpip.Timer {
return nil
return &nullTimer{}
}
type notificationChannels struct {