26 ms·
What if I have a blocking function call (i.e. listening on a socket)? Seems like there is no choice but to put the blocking call in its own thread...
by ythn 9y ago
What if I have a blocking function call (i.e. listening on a socket)? Seems like there is no choice but to put the blocking call in its own thread...
- rini17 9y agoAll modern operating systems support event interface to sockets (like select, epoll). And OP actually says that limiting usage of threads to handle blocking stuff is fine.
- littlestymaar 9y agoWhy should you use a blocking mecanism for listening on a socket ? Non-blocking I/Os[1] (epoll on Linux) have been a thing for a long time now. [1] : https://en.wikipedia.org/wiki/Asynchronous_I/O https://en.wikipedia.org/wiki/Asynchronous_I/O
- kbwt 9y agoExcept when the non-blocking file I/O API[1] is actually a blocking one. Yes, I realize in this case it's the API that needs fixing, but it isn't looking like that will happen anytime soon. [1] : https://lwn.net/Articles/723752/#724198 https://lwn.net/Articles/723752/#724198
- zzzeek 9y agoThe answer from anti threading proponents would say you should never use blocking IO.