]> Cypherpunks repositories - gostls13.git/commit
runtime: add "success" field to sudog
authorMatthew Dempsky <mdempsky@google.com>
Mon, 27 Jul 2020 19:40:18 +0000 (12:40 -0700)
committerMatthew Dempsky <mdempsky@google.com>
Tue, 18 Aug 2020 20:05:33 +0000 (20:05 +0000)
commit30a68bfb806b5217932e280f5a5f521237e69077
treec5c83a80382f8806db56dc3a2205cf881d25133f
parent861a9483357a1a13609430ec6684b3dc9209e80c
runtime: add "success" field to sudog

The current wakeup protocol for channel communications is that the
second goroutine sets gp.param to the sudog when a value is
successfully communicated over the channel, and to nil when the wakeup
is due to closing the channel.

Setting nil to indicate channel closure works okay for chansend and
chanrecv, because they're only communicating with one channel, so they
know it must be the channel that was closed. However, it means
selectgo has to re-poll all of the channels to figure out which one
was closed.

This commit adds a "success" field to sudog, and changes the wakeup
protocol to always set gp.param to sg, and to use sg.success to
indicate successful communication vs channel closure.

While here, this also reorganizes the chansend code slightly so that
the sudog is still released to the pool if the send blocks and then is
awoken because the channel closed.

Updates #40410.

Change-Id: I6cd9a20ebf9febe370a15af1b8afe24c5539efc6
Reviewed-on: https://go-review.googlesource.com/c/go/+/245019
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
src/runtime/chan.go
src/runtime/runtime2.go
src/runtime/select.go