var wg sync.WaitGroup
ints := make(chan int, 1)
done := make(chan bool)
go func() {
for i := 0; i < 3; i++ {
ints <- i
}
close(ints)
}()
f := func() {
wg.Add(1)
defer wg.Done()
for {
i, ok := <-ints
if !ok {
done <- true
return
}
}
}
exit:
for {
select {
case <-done:
break exit
default:
f()
}
}
wg.Wait()
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.