mirror of
https://github.com/golang/go
synced 2024-10-02 22:25:08 +00:00
runtime: convert worldIsStopped to atomic type
For #53821 Change-Id: I246b65ddb1171d2cab42f98092c64f20ecef392a Reviewed-on: https://go-review.googlesource.com/c/go/+/425778 Run-TryBot: Michael Pratt <mpratt@google.com> Reviewed-by: Heschi Kreinick <heschi@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Pratt <mpratt@google.com>
This commit is contained in:
parent
0d6a7f9d2e
commit
301ca7513f
|
@ -13,7 +13,7 @@ import (
|
|||
|
||||
// worldIsStopped is accessed atomically to track world-stops. 1 == world
|
||||
// stopped.
|
||||
var worldIsStopped uint32
|
||||
var worldIsStopped atomic.Uint32
|
||||
|
||||
// lockRankStruct is embedded in mutex
|
||||
type lockRankStruct struct {
|
||||
|
@ -301,7 +301,7 @@ func assertRankHeld(r lockRank) {
|
|||
//
|
||||
//go:nosplit
|
||||
func worldStopped() {
|
||||
if stopped := atomic.Xadd(&worldIsStopped, 1); stopped != 1 {
|
||||
if stopped := worldIsStopped.Add(1); stopped != 1 {
|
||||
systemstack(func() {
|
||||
print("world stop count=", stopped, "\n")
|
||||
throw("recursive world stop")
|
||||
|
@ -317,7 +317,7 @@ func worldStopped() {
|
|||
//
|
||||
//go:nosplit
|
||||
func worldStarted() {
|
||||
if stopped := atomic.Xadd(&worldIsStopped, -1); stopped != 0 {
|
||||
if stopped := worldIsStopped.Add(-1); stopped != 0 {
|
||||
systemstack(func() {
|
||||
print("world stop count=", stopped, "\n")
|
||||
throw("released non-stopped world stop")
|
||||
|
@ -329,7 +329,7 @@ func worldStarted() {
|
|||
//
|
||||
//go:nosplit
|
||||
func checkWorldStopped() bool {
|
||||
stopped := atomic.Load(&worldIsStopped)
|
||||
stopped := worldIsStopped.Load()
|
||||
if stopped > 1 {
|
||||
systemstack(func() {
|
||||
print("inconsistent world stop count=", stopped, "\n")
|
||||
|
|
Loading…
Reference in a new issue