for p.runqhead != p.runqtail {
// pop from tail of local queue
p.runqtail--
- gp := p.runq[p.runqtail%uint32(len(p.runq))]
+ gp := p.runq[p.runqtail%uint32(len(p.runq))].ptr()
// push onto head of global queue
globrunqputhead(gp)
}
h := atomicload(&_p_.runqhead) // load-acquire, synchronize with consumers
t := _p_.runqtail
if t-h < uint32(len(_p_.runq)) {
- _p_.runq[t%uint32(len(_p_.runq))] = gp
+ _p_.runq[t%uint32(len(_p_.runq))].set(gp)
atomicstore(&_p_.runqtail, t+1) // store-release, makes the item available for consumption
return
}
throw("runqputslow: queue is not full")
}
for i := uint32(0); i < n; i++ {
- batch[i] = _p_.runq[(h+i)%uint32(len(_p_.runq))]
+ batch[i] = _p_.runq[(h+i)%uint32(len(_p_.runq))].ptr()
}
if !cas(&_p_.runqhead, h, h+n) { // cas-release, commits consume
return false
if t == h {
return nil, false
}
- gp := _p_.runq[h%uint32(len(_p_.runq))]
+ gp := _p_.runq[h%uint32(len(_p_.runq))].ptr()
if cas(&_p_.runqhead, h, h+1) { // cas-release, commits consume
return gp, false
}
// Batch is a ring buffer starting at batchHead.
// Returns number of grabbed goroutines.
// Can be executed by any P.
-func runqgrab(_p_ *p, batch *[256]*g, batchHead uint32, stealRunNextG bool) uint32 {
+func runqgrab(_p_ *p, batch *[256]guintptr, batchHead uint32, stealRunNextG bool) uint32 {
for {
h := atomicload(&_p_.runqhead) // load-acquire, synchronize with other consumers
t := atomicload(&_p_.runqtail) // load-acquire, synchronize with the producer
if !_p_.runnext.cas(next, 0) {
continue
}
- batch[batchHead%uint32(len(batch))] = next.ptr()
+ batch[batchHead%uint32(len(batch))] = next
return 1
}
}
return nil
}
n--
- gp := _p_.runq[(t+n)%uint32(len(_p_.runq))]
+ gp := _p_.runq[(t+n)%uint32(len(_p_.runq))].ptr()
if n == 0 {
return gp
}