mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime: eliminate the redundant for loop in runqget()
Change-Id: If9b283bbef3ff12a64d34b07491aee3396852f05 Reviewed-on: https://go-review.googlesource.com/c/go/+/317509 Reviewed-by: Austin Clements <austin@google.com> Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Keith Randall <khr@golang.org>
This commit is contained in:
parent
f118d145a5
commit
3920d6f208
1 changed files with 6 additions and 8 deletions
|
|
@ -5994,14 +5994,12 @@ func runqputbatch(pp *p, q *gQueue, qsize int) {
|
||||||
// Executed only by the owner P.
|
// Executed only by the owner P.
|
||||||
func runqget(_p_ *p) (gp *g, inheritTime bool) {
|
func runqget(_p_ *p) (gp *g, inheritTime bool) {
|
||||||
// If there's a runnext, it's the next G to run.
|
// If there's a runnext, it's the next G to run.
|
||||||
for {
|
next := _p_.runnext
|
||||||
next := _p_.runnext
|
// If the runnext is non-0 and the CAS fails, it could only have been stolen by another P,
|
||||||
if next == 0 {
|
// because other Ps can race to set runnext to 0, but only the current P can set it to non-0.
|
||||||
break
|
// Hence, there's no need to retry this CAS if it falls.
|
||||||
}
|
if next != 0 && _p_.runnext.cas(next, 0) {
|
||||||
if _p_.runnext.cas(next, 0) {
|
return next.ptr(), true
|
||||||
return next.ptr(), true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for {
|
for {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue