I think it is as simple as looking at kselect/poll in posix. Each descriptor can be viewed as an independent channel of info/objects.
Select with Go channels works similarly and has similar usefulness. > On Apr 3, 2023, at 7:00 PM, Nigel Tao <nigel...@golang.org> wrote: > > On Mon, Apr 3, 2023 at 8:14 PM Rob Pike <r...@golang.org> wrote: >> select { >> case <-ticker.C: >> case <-pauseC: >> <-pauseC >> } > > This one is more interesting. You can't combine the ticker.C and the > pauseC into a single heterogenous channel because you want to wait for > the second pause event (a resumption) without dropping or buffering > arbitrarily many other ticker events. > > I take the general point that sometimes you're waiting on only a > subset of incoming events. > > For this particular code, though, I think you could structure it a > different way. Instead of two channels with (ticker) events and > (pause, resume) events, you could have two channels with heterogenous > (ticker, pause) events and (resume) events. Yes, the `time.NewTicker` > API equivalent would have to be passed a channel instead of returning > a channel. The `case ' ': pauseC <- 1` code would have to alternate > which channel it sent on. But we could eliminate the select. > > To be clear, it's not that the code is better / simpler / cleaner if > we eliminate selects. It's that, outside of Go, if we don't have > selects, what becomes unworkably complicated enough that it's worth > implementing selects. > > -- > 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/CAOeFMNVZcoj8kp%3DDeaVqs55FiNcJrbPGPAUuLOLj0gUWqCRJKg%40mail.gmail.com. -- 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/F7DC219C-7693-4A93-A801-7013E3FCD988%40ix.netcom.com.