]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: use gList in closechan
authorAustin Clements <austin@google.com>
Fri, 10 Aug 2018 14:34:41 +0000 (10:34 -0400)
committerAustin Clements <austin@google.com>
Mon, 20 Aug 2018 18:19:29 +0000 (18:19 +0000)
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>
src/runtime/chan.go

index ce71cee4c5b40d9bafaaf3f07b59e27911ac46a4..615643e6a60bddc3f9aa6fe3123cd108e0815162 100644 (file)
@@ -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)
        }