From 204a024dae66d50108de3b22f9762b4b89541a6a Mon Sep 17 00:00:00 2001 From: Sameer Ajmani Date: Mon, 17 Mar 2014 12:45:17 -0400 Subject: go.blog: update pipelines blog post to clarify a point of confusion. LGTM=bcmills R=david.crawshaw, rsc, bcmills CC=adg, golang-codereviews, r https://golang.org/cl/76910043 --- content/pipelines/sqdone3.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'content/pipelines/sqdone3.go') diff --git a/content/pipelines/sqdone3.go b/content/pipelines/sqdone3.go index 63a2269..7000744 100644 --- a/content/pipelines/sqdone3.go +++ b/content/pipelines/sqdone3.go @@ -26,7 +26,7 @@ func sq(done <-chan struct{}, in <-chan int) <-chan int { select { case out <- n * n: case <-done: - return + return // HL } } }() @@ -44,15 +44,17 @@ func merge(done <-chan struct{}, cs ...<-chan int) <-chan int { // copies values from c to out until c or done is closed, then calls // wg.Done. output := func(c <-chan int) { - defer wg.Done() + defer wg.Done() // HL for n := range c { select { case out <- n: case <-done: - return + return // HL } } } + // ... the rest is unchanged ... + wg.Add(len(cs)) for _, c := range cs { go output(c) -- cgit v1.2.3