4 ms·
Au contraire: Go has a built-in 'select' keyword that lets you wait on a set of arbitrary (blocking) channel operations. Start up blocking I/O in goroutines, an
by azernik 10y ago
Au contraire: Go has a built-in 'select' keyword that lets you wait on a set of arbitrary (blocking) channel operations. Start up blocking I/O in goroutines, and select on channels that give you the results.
- Groxx 10y agoA goroutine is a "task" though. And typically you spin up a goroutine for your select, and hang your current goroutine on its completion. Seems pretty similar to me.
- azernik 10y agoFor networking, it's using epoll() under the scenes; depends on what exact non-blocking operation you're using, though. See this very very old HN thread: https://news.ycombinator.com/item?id=3565703 https://news.ycombinator.com/item?id=3565703 (Hopefully the standard library has improved since then.)
- deleted 10y ago[deleted]
- neilc 10y agoChannels are not network sockets; select cannot be used to wait on a set of network sockets. (Early versions of Go had a "network channel" concept, but that was removed from the language: https://softwareengineering.stackexchange.com/questions/154004/why-did-golang-discontinue-the-netchan-package https://softwareengineering.stackexchange.com/questions/1540...)
- coldtea 10y agoThat's not access to the raw system's select/epoll. It just happens to offer a similar model (and have a select operation).
- lobster_johnson 10y agoselect{} has nothing to with select(), epoll etc. It works on channels only, which are not implemented using those syscalls.