ktime: simplify Listener.NotifyTimer()

No implementations of Listener use the Setting argument or the ability to
override the new Setting, so remove these.

PiperOrigin-RevId: 694195729
This commit is contained in:
Jamie Liu
2024-11-07 11:47:58 -08:00
committed by gVisor bot
parent 7a039fc8c5
commit 379108ca91
5 changed files with 12 additions and 30 deletions
+1 -2
View File
@@ -142,8 +142,7 @@ func (tfd *TimerFileDescription) Release(context.Context) {
}
// NotifyTimer implements ktime.TimerListener.NotifyTimer.
func (tfd *TimerFileDescription) NotifyTimer(exp uint64, setting ktime.Setting) (ktime.Setting, bool) {
func (tfd *TimerFileDescription) NotifyTimer(exp uint64) {
tfd.val.Add(exp)
tfd.events.Notify(waiter.ReadableEvents)
return ktime.Setting{}, false
}
+3 -5
View File
@@ -114,9 +114,9 @@ func (it *IntervalTimer) signalRejectedLocked() {
}
// NotifyTimer implements ktime.TimerListener.NotifyTimer.
func (it *IntervalTimer) NotifyTimer(exp uint64, setting ktime.Setting) (ktime.Setting, bool) {
func (it *IntervalTimer) NotifyTimer(exp uint64) {
if it.target == nil {
return ktime.Setting{}, false
return
}
sh := it.target.tg.signalLock()
@@ -124,7 +124,7 @@ func (it *IntervalTimer) NotifyTimer(exp uint64, setting ktime.Setting) (ktime.S
if it.sigpending {
it.overrunCur += exp
return ktime.Setting{}, false
return
}
// sigpending must be set before sendSignalTimerLocked() so that it can be
@@ -143,8 +143,6 @@ func (it *IntervalTimer) NotifyTimer(exp uint64, setting ktime.Setting) (ktime.S
if err := it.target.sendSignalTimerLocked(si, it.group, it); err != nil {
it.signalRejectedLocked()
}
return ktime.Setting{}, false
}
// IntervalTimerCreate implements timer_create(2).
+1 -2
View File
@@ -658,7 +658,6 @@ type itimerRealListener struct {
}
// NotifyTimer implements ktime.TimerListener.NotifyTimer.
func (l *itimerRealListener) NotifyTimer(exp uint64, setting ktime.Setting) (ktime.Setting, bool) {
func (l *itimerRealListener) NotifyTimer(exp uint64) {
l.tg.SendSignal(SignalInfoPriv(linux.SIGALRM))
return ktime.Setting{}, false
}
+6 -19
View File
@@ -298,11 +298,8 @@ type Listener interface {
// Notify is called with the associated Timer's mutex locked, so Notify
// must not take any locks that precede Timer.mu in lock order.
//
// If Notify returns true, the timer will use the returned setting
// rather than the passed one.
//
// Preconditions: exp > 0.
NotifyTimer(exp uint64, setting Setting) (newSetting Setting, update bool)
NotifyTimer(exp uint64)
}
// Setting contains user-controlled mutable Timer properties.
@@ -551,9 +548,7 @@ func (t *Timer) Tick() {
s, exp := t.setting.At(now)
t.setting = s
if exp > 0 {
if newS, ok := t.listener.NotifyTimer(exp, t.setting); ok {
t.setting = newS
}
t.listener.NotifyTimer(exp)
}
t.resetKickerLocked(now)
}
@@ -617,9 +612,7 @@ func (t *Timer) Get() (Time, Setting) {
s, exp := t.setting.At(now)
t.setting = s
if exp > 0 {
if newS, ok := t.listener.NotifyTimer(exp, t.setting); ok {
t.setting = newS
}
t.listener.NotifyTimer(exp)
}
t.resetKickerLocked(now)
return now, s
@@ -659,9 +652,7 @@ func (t *Timer) SwapAnd(s Setting, f func()) (Time, Setting) {
}
oldS, oldExp := t.setting.At(now)
if oldExp > 0 {
t.listener.NotifyTimer(oldExp, oldS)
// N.B. The returned Setting doesn't matter because we're about
// to overwrite.
t.listener.NotifyTimer(oldExp)
}
if f != nil {
f()
@@ -669,9 +660,7 @@ func (t *Timer) SwapAnd(s Setting, f func()) (Time, Setting) {
newS, newExp := s.At(now)
t.setting = newS
if newExp > 0 {
if newS, ok := t.listener.NotifyTimer(newExp, t.setting); ok {
t.setting = newS
}
t.listener.NotifyTimer(newExp)
}
t.resetKickerLocked(now)
return now, oldS
@@ -730,11 +719,9 @@ func NewChannelNotifier() (Listener, <-chan struct{}) {
}
// NotifyTimer implements Listener.NotifyTimer.
func (c ChannelNotifier) NotifyTimer(uint64, Setting) (Setting, bool) {
func (c ChannelNotifier) NotifyTimer(uint64) {
select {
case c <- struct{}{}:
default:
}
return Setting{}, false
}
+1 -2
View File
@@ -122,7 +122,6 @@ type functionNotifier struct {
}
// NotifyTimer implements ktime.TimerListener.NotifyTimer.
func (f *functionNotifier) NotifyTimer(uint64, Setting) (Setting, bool) {
func (f *functionNotifier) NotifyTimer(uint64) {
f.fn()
return Setting{}, false
}