func checkTimers(pp *p, now int64) (rnow, pollUntil int64, ran bool) {
// If it's not yet time for the first timer, or the first adjusted
// timer, then there is nothing to do.
- next := int64(pp.timer0When.Load())
- nextAdj := int64(pp.timerModifiedEarliest.Load())
+ next := pp.timer0When.Load()
+ nextAdj := pp.timerModifiedEarliest.Load()
if next == 0 || (nextAdj != 0 && nextAdj < next) {
next = nextAdj
}
// The when field of the first entry on the timer heap.
// This is 0 if the timer heap is empty.
- timer0When atomic.Uint64
+ timer0When atomic.Int64
// The earliest known nextwhen field of a timer with
// timerModifiedEarlier status. Because the timer may have been
// modified again, there need not be any timer with this value.
// This is 0 if there are no timerModifiedEarlier timers.
- timerModifiedEarliest atomic.Uint64
+ timerModifiedEarliest atomic.Int64
// Per-P GC state
gcAssistTime int64 // Nanoseconds in assistAlloc
pp.timers = append(pp.timers, t)
siftupTimer(pp.timers, i)
if t == pp.timers[0] {
- pp.timer0When.Store(uint64(t.when))
+ pp.timer0When.Store(t.when)
}
atomic.Xadd(&pp.numTimers, 1)
}
// We'll postpone looking through all the adjusted timers until
// one would actually expire.
first := pp.timerModifiedEarliest.Load()
- if first == 0 || int64(first) > now {
+ if first == 0 || first > now {
if verifyTimers {
verifyTimerHeap(pp)
}
//
//go:nowritebarrierrec
func nobarrierWakeTime(pp *p) int64 {
- next := int64(pp.timer0When.Load())
- nextAdj := int64(pp.timerModifiedEarliest.Load())
+ next := pp.timer0When.Load()
+ nextAdj := pp.timerModifiedEarliest.Load()
if next == 0 || (nextAdj != 0 && nextAdj < next) {
next = nextAdj
}
if len(pp.timers) == 0 {
pp.timer0When.Store(0)
} else {
- pp.timer0When.Store(uint64(pp.timers[0].when))
+ pp.timer0When.Store(pp.timers[0].when)
}
}
return
}
- if pp.timerModifiedEarliest.CompareAndSwap(old, uint64(nextwhen)) {
+ if pp.timerModifiedEarliest.CompareAndSwap(old, nextwhen) {
return
}
}
continue
}
- w := int64(pp.timer0When.Load())
+ w := pp.timer0When.Load()
if w != 0 && w < next {
next = w
}
- w = int64(pp.timerModifiedEarliest.Load())
+ w = pp.timerModifiedEarliest.Load()
if w != 0 && w < next {
next = w
}