1

I would like to define a function that waits for an unknown number of channels to receive and then informs another channel called allDone about the completion.

I'm not sure how to list select cases programmatically either, some pseudo code might look like this:

func waitFor(channels ...chan bool, allDone chan bool) {
    for {
        select {
        case <-channels[0]:

        ...

        case <-channels[len(channels)-1]:
            allDone <- true
        }
    }
}
zianwar
  • 3,642
  • 3
  • 28
  • 37

0 Answers0