mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
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:
committed by
gVisor bot
parent
3cbd2127f0
commit
3d4743d960
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user