mirror of
https://github.com/golang/go
synced 2024-11-23 01:30:02 -07:00
runtime: convert g.selectDone to atomic type
On the write side, g.selectDone has been converted from non-atomic to atomic access. For #53821. Change-Id: Iac46bc6acce7eed51dfd990285dd57f0d58b4ae2 Reviewed-on: https://go-review.googlesource.com/c/go/+/425414 Run-TryBot: hopehook <hopehook@qq.com> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
parent
7a1ae605eb
commit
951d2c657d
@ -791,7 +791,7 @@ func (q *waitq) dequeue() *sudog {
|
|||||||
// We use a flag in the G struct to tell us when someone
|
// We use a flag in the G struct to tell us when someone
|
||||||
// else has won the race to signal this goroutine but the goroutine
|
// else has won the race to signal this goroutine but the goroutine
|
||||||
// hasn't removed itself from the queue yet.
|
// hasn't removed itself from the queue yet.
|
||||||
if sgp.isSelect && !atomic.Cas(&sgp.g.selectDone, 0, 1) {
|
if sgp.isSelect && !sgp.g.selectDone.CompareAndSwap(0, 1) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -487,7 +487,7 @@ type g struct {
|
|||||||
cgoCtxt []uintptr // cgo traceback context
|
cgoCtxt []uintptr // cgo traceback context
|
||||||
labels unsafe.Pointer // profiler labels
|
labels unsafe.Pointer // profiler labels
|
||||||
timer *timer // cached timer for time.Sleep
|
timer *timer // cached timer for time.Sleep
|
||||||
selectDone uint32 // are we participating in a select and did someone win the race?
|
selectDone atomic.Uint32 // are we participating in a select and did someone win the race?
|
||||||
|
|
||||||
// goroutineProfiled indicates the status of this goroutine's stack for the
|
// goroutineProfiled indicates the status of this goroutine's stack for the
|
||||||
// current in-progress goroutine profile
|
// current in-progress goroutine profile
|
||||||
|
@ -329,7 +329,7 @@ func selectgo(cas0 *scase, order0 *uint16, pc0 *uintptr, nsends, nrecvs int, blo
|
|||||||
|
|
||||||
sellock(scases, lockorder)
|
sellock(scases, lockorder)
|
||||||
|
|
||||||
gp.selectDone = 0
|
gp.selectDone.Store(0)
|
||||||
sg = (*sudog)(gp.param)
|
sg = (*sudog)(gp.param)
|
||||||
gp.param = nil
|
gp.param = nil
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user