Great, thanks! On Mon, 28 Mar 2022 at 12:53, Steven Hartland <ste...@multiplay.co.uk> wrote:
> No problem, there's a nice little write up on it stackoverflow > <https://stackoverflow.com/questions/47645808/how-does-select-work-when-multiple-channels-are-involved> > . > > On Mon, 28 Mar 2022 at 17:41, Gowtham Raj <rgowtham...@gmail.com> wrote: > >> Hello Steven, >> >> Wow, this solved the problem. Never saw this pattern before. Thanks for >> your help !! >> If you have any reference material for further reading for patterns like >> this can you please share them. >> >> Regards, >> Gowtham >> >> On Mon, 28 Mar 2022 at 12:21, Steven Hartland <ste...@multiplay.co.uk> >> wrote: >> >>> There is no guarantee that the select chooses the done case, so you need >>> to check in work case as well e.g. >>> https://go.dev/play/p/zAj_qfO4uMA >>> >>> On Mon, 28 Mar 2022 at 16:54, Gowtham Raj <rgowtham...@gmail.com> wrote: >>> >>>> In this example, we have a *worker*. The idea here is simulate clean >>>> shutdown of all go routines based on a condition. >>>> >>>> In this case, go routines get spun - based on workers count. Each go >>>> routine reads the channel, does some work and sends output to the >>>> outputChannel. >>>> >>>> The main go routine reads this output and prints it. To simulate a stop >>>> condition, the doneChannel is closed. Expected outcome is that select >>>> inside >>>> each go routine will pick this up and execute return which in turn >>>> will call the defer println. The actual output is that it never gets >>>> called and main exits. >>>> >>>> Not sure what's the reason behind this. >>>> >>>> Code at *https://go.dev/play/p/-R7Llw9X_6U >>>> <https://go.dev/play/p/-R7Llw9X_6U> * >>>> >>>> Can you please help to figure out the bug in this code. >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "golang-nuts" group. >>>> To unsubscribe from this group and stop receiving emails from it, send >>>> an email to golang-nuts+unsubscr...@googlegroups.com. >>>> To view this discussion on the web visit >>>> https://groups.google.com/d/msgid/golang-nuts/3762b074-63c5-407e-9515-6833465dc94en%40googlegroups.com >>>> <https://groups.google.com/d/msgid/golang-nuts/3762b074-63c5-407e-9515-6833465dc94en%40googlegroups.com?utm_medium=email&utm_source=footer> >>>> . >>>> >>> -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAE-6Q_LFTRHdoCtNBn868S8WvL%3DppsomJUQYUf0p4HkPsub_Wg%40mail.gmail.com.