Re: using select() without blocking the runloop
Jack Brindle
If file handlers were thread-specific you would not be able to read files on other threads. They are process-specific, not thread-specific.
toggle quoted message
Show quoted text
At its core, select is very much synchronous. This haunted the Mac file system until the network folks started using KQueues to handle the descriptors. GCD made this much easier with dispatch sources based on KQueue elements. What I suspect you really want to do is to create a dispatch_source using DISPATCH_SOURCE_TYPE READ and DISPATCH_SOURCE_TYPE_WRITE. so that you don’t block, instead letting the system do the chore for you. Apple has some pretty good docs on this in their Dispatch guide. It is worth reading. They also have (or at least used to) an interesting sample source that demonstrates the use of various dispatch source features, done in command-line type programs. A search for it is definitely worth while. This isn’t all that difficult to do, and if you really need to use select() is by far the best way to go. - Jack On Nov 24, 2017, at 1:36 AM, Roland King <rols@...> wrote: |
|