Under the section “Explicit cancellation”, main goroutine broadcasts its denial to receive any more data but it broadcasts, seemingly, to “merge” and “sq” upstream goroutines only (not to “gen” goroutine).
In this situation, since “sq” stage would not be attempting to accept data from inbound channels from “gen”, I think it is probable to have resource leak since “gen” would be blocked indefinitely.
Is my understanding correct or am I missing something. Please explain.
Just looking quickly at the blog post, gen was rewritten in the section prior to “Explicit cancellation” to use a len(input)-buffered channel and not be a goroutine at all. Probably the intention is that that implementation is kept in the next section.
So basically, this gen (with buffered channel) implementation does not care if the receiver has abandoned the inbound channel from gen! Thanks for the answer, it did clear me my question!! Thanks again.