aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAustin Clements <austin@google.com>2018-08-10 10:34:41 -0400
committerAustin Clements <austin@google.com>2018-08-20 18:19:29 +0000
commita034f310b040a4252843683f59555ded07016eae (patch)
tree174dc4d9b39c45fae948cbe5b0d096ecea7b87e1
parent083938df14c0602a44d055bd3f4427980cf51c27 (diff)
downloadgo-a034f310b040a4252843683f59555ded07016eae.tar.gz
go-a034f310b040a4252843683f59555ded07016eae.zip
runtime: use gList in closechan
Change-Id: I8148eb17fe9f2cbb659c35d84cdd212b46dc23bf Reviewed-on: https://go-review.googlesource.com/129401 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rick Hudson <rlh@golang.org>
-rw-r--r--src/runtime/chan.go13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/runtime/chan.go b/src/runtime/chan.go
index ce71cee4c5..615643e6a6 100644
--- a/src/runtime/chan.go
+++ b/src/runtime/chan.go
@@ -343,7 +343,7 @@ func closechan(c *hchan) {
c.closed = 1
- var glist *g
+ var glist gList
// release all readers
for {
@@ -363,8 +363,7 @@ func closechan(c *hchan) {
if raceenabled {
raceacquireg(gp, unsafe.Pointer(c))
}
- gp.schedlink.set(glist)
- glist = gp
+ glist.push(gp)
}
// release all writers (they will panic)
@@ -382,15 +381,13 @@ func closechan(c *hchan) {
if raceenabled {
raceacquireg(gp, unsafe.Pointer(c))
}
- gp.schedlink.set(glist)
- glist = gp
+ glist.push(gp)
}
unlock(&c.lock)
// Ready all Gs now that we've dropped the channel lock.
- for glist != nil {
- gp := glist
- glist = glist.schedlink.ptr()
+ for !glist.empty() {
+ gp := glist.pop()
gp.schedlink = 0
goready(gp, 3)
}