mirror of
https://github.com/golang/go
synced 2024-11-02 11:50:30 +00:00
runtime: convert kqueue netpollWakeSig to atomic type
Updates #53821 Change-Id: I85d7444be36967e1e7e0ff2ce2f19b73581ecdde Reviewed-on: https://go-review.googlesource.com/c/go/+/423880 Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Keith Randall <khr@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
This commit is contained in:
parent
9b988c9094
commit
04d8c2327d
1 changed files with 3 additions and 3 deletions
|
@ -18,7 +18,7 @@ var (
|
|||
|
||||
netpollBreakRd, netpollBreakWr uintptr // for netpollBreak
|
||||
|
||||
netpollWakeSig uint32 // used to avoid duplicate calls of netpollBreak
|
||||
netpollWakeSig atomic.Uint32 // used to avoid duplicate calls of netpollBreak
|
||||
)
|
||||
|
||||
func netpollinit() {
|
||||
|
@ -84,7 +84,7 @@ func netpollarm(pd *pollDesc, mode int) {
|
|||
// netpollBreak interrupts a kevent.
|
||||
func netpollBreak() {
|
||||
// Failing to cas indicates there is an in-flight wakeup, so we're done here.
|
||||
if !atomic.Cas(&netpollWakeSig, 0, 1) {
|
||||
if !netpollWakeSig.CompareAndSwap(0, 1) {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -155,7 +155,7 @@ retry:
|
|||
// if blocking.
|
||||
var tmp [16]byte
|
||||
read(int32(netpollBreakRd), noescape(unsafe.Pointer(&tmp[0])), int32(len(tmp)))
|
||||
atomic.Store(&netpollWakeSig, 0)
|
||||
netpollWakeSig.Store(0)
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue