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(atomic.Load64(&pp.timer0When))
+ next := int64(pp.timer0When.Load())
nextAdj := int64(atomic.Load64(&pp.timerModifiedEarliest))
if next == 0 || (nextAdj != 0 && nextAdj < next) {
next = nextAdj
pp.timers = nil
pp.numTimers = 0
pp.deletedTimers = 0
- atomic.Store64(&pp.timer0When, 0)
+ pp.timer0When.Store(0)
unlock(&pp.timersLock)
unlock(&plocal.timersLock)
}
_ uint32 // Alignment for atomic fields below
// The when field of the first entry on the timer heap.
- // This is updated using atomic functions.
// This is 0 if the timer heap is empty.
- timer0When uint64
+ timer0When atomic.Uint64
// The earliest known nextwhen field of a timer with
// timerModifiedEarlier status. Because the timer may have been
pp.timers = append(pp.timers, t)
siftupTimer(pp.timers, i)
if t == pp.timers[0] {
- atomic.Store64(&pp.timer0When, uint64(t.when))
+ pp.timer0When.Store(uint64(t.when))
}
atomic.Xadd(&pp.numTimers, 1)
}
//
//go:nowritebarrierrec
func nobarrierWakeTime(pp *p) int64 {
- next := int64(atomic.Load64(&pp.timer0When))
+ next := int64(pp.timer0When.Load())
nextAdj := int64(atomic.Load64(&pp.timerModifiedEarliest))
if next == 0 || (nextAdj != 0 && nextAdj < next) {
next = nextAdj
// The caller must have locked the timers for pp.
func updateTimer0When(pp *p) {
if len(pp.timers) == 0 {
- atomic.Store64(&pp.timer0When, 0)
+ pp.timer0When.Store(0)
} else {
- atomic.Store64(&pp.timer0When, uint64(pp.timers[0].when))
+ pp.timer0When.Store(uint64(pp.timers[0].when))
}
}
continue
}
- w := int64(atomic.Load64(&pp.timer0When))
+ w := int64(pp.timer0When.Load())
if w != 0 && w < next {
next = w
}