mirror of
https://github.com/golang/go
synced 2024-11-23 05:10:09 -07:00
runtime: convert netpoll netpollInited to atomic type
Updates #53821 Change-Id: Ifa2e5f5d4047117b1887c1e56851355547bb4f33 Reviewed-on: https://go-review.googlesource.com/c/go/+/423881 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Keith Randall <khr@google.com> Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Michael Pratt <mpratt@google.com>
This commit is contained in:
parent
04d8c2327d
commit
dea67a9b34
@ -177,7 +177,7 @@ type pollCache struct {
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
netpollInitLock mutex
|
netpollInitLock mutex
|
||||||
netpollInited uint32
|
netpollInited atomic.Uint32
|
||||||
|
|
||||||
pollcache pollCache
|
pollcache pollCache
|
||||||
netpollWaiters uint32
|
netpollWaiters uint32
|
||||||
@ -189,19 +189,19 @@ func poll_runtime_pollServerInit() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func netpollGenericInit() {
|
func netpollGenericInit() {
|
||||||
if atomic.Load(&netpollInited) == 0 {
|
if netpollInited.Load() == 0 {
|
||||||
lockInit(&netpollInitLock, lockRankNetpollInit)
|
lockInit(&netpollInitLock, lockRankNetpollInit)
|
||||||
lock(&netpollInitLock)
|
lock(&netpollInitLock)
|
||||||
if netpollInited == 0 {
|
if netpollInited.Load() == 0 {
|
||||||
netpollinit()
|
netpollinit()
|
||||||
atomic.Store(&netpollInited, 1)
|
netpollInited.Store(1)
|
||||||
}
|
}
|
||||||
unlock(&netpollInitLock)
|
unlock(&netpollInitLock)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func netpollinited() bool {
|
func netpollinited() bool {
|
||||||
return atomic.Load(&netpollInited) != 0
|
return netpollInited.Load() != 0
|
||||||
}
|
}
|
||||||
|
|
||||||
//go:linkname poll_runtime_isPollServerDescriptor internal/poll.runtime_isPollServerDescriptor
|
//go:linkname poll_runtime_isPollServerDescriptor internal/poll.runtime_isPollServerDescriptor
|
||||||
|
@ -8,7 +8,7 @@ package runtime
|
|||||||
|
|
||||||
import "runtime/internal/atomic"
|
import "runtime/internal/atomic"
|
||||||
|
|
||||||
var netpollInited uint32
|
var netpollInited atomic.Uint32
|
||||||
var netpollWaiters uint32
|
var netpollWaiters uint32
|
||||||
|
|
||||||
var netpollStubLock mutex
|
var netpollStubLock mutex
|
||||||
@ -19,7 +19,7 @@ var netpollBrokenLock mutex
|
|||||||
var netpollBroken bool
|
var netpollBroken bool
|
||||||
|
|
||||||
func netpollGenericInit() {
|
func netpollGenericInit() {
|
||||||
atomic.Store(&netpollInited, 1)
|
netpollInited.Store(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
func netpollBreak() {
|
func netpollBreak() {
|
||||||
@ -57,5 +57,5 @@ func netpoll(delay int64) gList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func netpollinited() bool {
|
func netpollinited() bool {
|
||||||
return atomic.Load(&netpollInited) != 0
|
return netpollInited.Load() != 0
|
||||||
}
|
}
|
||||||
|
@ -289,7 +289,7 @@ func addtimer(t *timer) {
|
|||||||
func doaddtimer(pp *p, t *timer) {
|
func doaddtimer(pp *p, t *timer) {
|
||||||
// Timers rely on the network poller, so make sure the poller
|
// Timers rely on the network poller, so make sure the poller
|
||||||
// has started.
|
// has started.
|
||||||
if netpollInited == 0 {
|
if netpollInited.Load() == 0 {
|
||||||
netpollGenericInit()
|
netpollGenericInit()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user