3 ms·
select() is useful on platforms without any poll variants.
by kevin_thibedeau 6y ago
select() is useful on platforms without any poll variants.
- bonzini 6y agoOf which the only one left is Windows, where you probably have a completely different event loop anyway. The Windows select by the way does not have the limitations on the file descriptor that the article talks about, because Windows file descriptors are not small consecutive integers.
- beagle3 6y ago…… and at least until 2011 which was when I last checked, select() was the reliable way to do usleep() in Windows without having to change system time granularity, set up invisible windows with their own message pump or a variety of other weird and unreliable ways.
- kevin_thibedeau 6y agoThere are plenty of embedded platforms in the same boat.
- deleted 6y ago[deleted]
- geertj 6y agoActually that’s not totally accurate. The native IO model in the Win32 subsystem, I/O completion ports, is indeed completion based. But the NT kernel does have a scalable readiness model too, limited to sockets, that people have used to build an epoll(). See: https://github.com/piscisaureus/wepoll https://github.com/piscisaureus/wepoll. This is used by e.g. deno and node.
- the_mitsuhiko 5y agoselect() on windows is kinda fine. It uses an actual array in fd_set and you can increase the array length by defining a constant or passing a custom structure.
- swiley 5y agoYou might be surprised at how little standards like POSIX actually cover. There are huge gaps in the APIs implemented by e.g. QNX. (I haven't checked if this specifically is one of them but I would be surprised if it isn't.)