// if they differ the descriptor was reused or timers were reset.
pd.rt.arg = pd.makeArg()
pd.rt.seq = pd.rseq
- resettimer(&pd.rt, pd.rd)
+ pd.rt.reset(pd.rd)
}
} else if pd.rd != rd0 || combo != combo0 {
pd.rseq++ // invalidate current timers
if pd.rd > 0 {
- modtimer(&pd.rt, pd.rd, 0, rtf, pd.makeArg(), pd.rseq)
+ pd.rt.modify(pd.rd, 0, rtf, pd.makeArg(), pd.rseq)
} else {
- deltimer(&pd.rt)
+ pd.rt.stop()
pd.rt.f = nil
}
}
pd.wt.f = netpollWriteDeadline
pd.wt.arg = pd.makeArg()
pd.wt.seq = pd.wseq
- resettimer(&pd.wt, pd.wd)
+ pd.wt.reset(pd.wd)
}
} else if pd.wd != wd0 || combo != combo0 {
pd.wseq++ // invalidate current timers
if pd.wd > 0 && !combo {
- modtimer(&pd.wt, pd.wd, 0, netpollWriteDeadline, pd.makeArg(), pd.wseq)
+ pd.wt.modify(pd.wd, 0, netpollWriteDeadline, pd.makeArg(), pd.wseq)
} else {
- deltimer(&pd.wt)
+ pd.wt.stop()
pd.wt.f = nil
}
}
rg = netpollunblock(pd, 'r', false, &delta)
wg = netpollunblock(pd, 'w', false, &delta)
if pd.rt.f != nil {
- deltimer(&pd.rt)
+ pd.rt.stop()
pd.rt.f = nil
}
if pd.wt.f != nil {
- deltimer(&pd.wt)
+ pd.wt.stop()
pd.wt.f = nil
}
unlock(&pd.lock)
// timer function, goroutineReady, before the goroutine has been parked.
func resetForSleep(gp *g, ut unsafe.Pointer) bool {
t := (*timer)(ut)
- resettimer(t, t.nextWhen)
+ t.reset(t.nextWhen)
return true
}
if t.state.Load() != 0 {
throw("startTimer called with initialized timer")
}
- resettimer(t, t.when)
+ t.reset(t.when)
}
// stopTimer stops a timer.
//
//go:linkname stopTimer time.stopTimer
func stopTimer(t *timer) bool {
- return deltimer(t)
+ return t.stop()
}
// resetTimer resets an inactive timer, adding it to the heap.
if raceenabled {
racerelease(unsafe.Pointer(t))
}
- return resettimer(t, when)
+ return t.reset(when)
}
// modTimer modifies an existing timer.
//
//go:linkname modTimer time.modTimer
func modTimer(t *timer, when, period int64) {
- modtimer(t, when, period, t.f, t.arg, t.seq)
+ t.modify(when, period, t.f, t.arg, t.seq)
}
// Go runtime.
pp.numTimers.Add(1)
}
-// deltimer deletes the timer t. It may be on some other P, so we can't
-// actually remove it from the timers heap. We can only mark it as deleted.
+// stop deletes the timer t. It may be on some other P, so we can't
+// actually remove it from the timers heap. We can only mark it as stopped.
// It will be removed in due course by the P whose heap it is on.
-// Reports whether the timer was removed before it was run.
-func deltimer(t *timer) bool {
+// Reports whether the timer was stopped before it was run.
+func (t *timer) stop() bool {
state, mp := t.lock()
if state&timerHeaped != 0 && (state&timerNextWhen == 0 || t.nextWhen != 0) {
// Timer pending: stop it.
}
}
-// modtimer modifies an existing timer.
+// modify modifies an existing timer.
// This is called by the netpoll code or time.Ticker.Reset or time.Timer.Reset.
// Reports whether the timer was modified before it was run.
-func modtimer(t *timer, when, period int64, f func(any, uintptr), arg any, seq uintptr) bool {
+func (t *timer) modify(when, period int64, f func(any, uintptr), arg any, seq uintptr) bool {
if when <= 0 {
throw("timer when must be positive")
}
return pending
}
-// resettimer resets the time when a timer should fire.
+// reset resets the time when a timer should fire.
// If used for an inactive timer, the timer will become active.
// Reports whether the timer was active and was stopped.
-func resettimer(t *timer, when int64) bool {
- return modtimer(t, when, t.period, t.f, t.arg, t.seq)
+func (t *timer) reset(when int64) bool {
+ return t.modify(when, t.period, t.f, t.arg, t.seq)
}
// cleantimers cleans up the head of the timer queue. This speeds up