sunfmin / fanout

Fanout - make writing parallel code even easier

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Do we need done channel?

BharathMG opened this issue · comments

commented

Hi!
Thanks for this awesome helper!

Just one doubt. Do we need done channel? I think the reason for using done channel in this is to exit the goroutines once the main exits. Pls correct me if I'm wrong!

So once the main exits, as per the go design spec, we don't have to wait for them. http://stackoverflow.com/questions/25518531/ok-to-exit-program-with-active-goroutine

Go will cleanup the goroutines when there are no more references to them. Are there any other uses for using the done channel? Thanks !

the ParallelRun could be used in long running process like your app server?

I tried remove the done channel, It seems still works. But I still can't confirm it's not needed. Could you try to ask on golang-nuts@googlegroups.com, See what other explanation it might have, since the article http://blog.golang.org/pipelines has been there for quite a long time, and Nobody have doubted it yet.

Cool answer from Ian Lance Taylor

If you are going to exit anyhow, don't worry about it.

Arranging for clean shutdown of running goroutines is only important
for a long-running program such as a network server.