News for hackers. Stuff that matters.
Re:Go Concurrency Patterns: Pipelines and cancellation by Sajmani on Friday March 14, 2014 @07:09AM (#7397976)
Yes, interrupt is better, and the article explains how to do that a few paragraphs later:

        for n := range in {
            select {
            case out <- n * n:
            case <-done:
                return
            }
        }
If you allow pipeline stages to interrupt their receive loop instead of draining the inbound channel, then _all_ send operations need to be governed by done. Otherwise the interrupted receive loop may block the upstream sender.

There are no comments on this comment yet.