Someone broke NSFileHandles pointing to pipes on mingw, so I am looking at the right way to fix it.

Ok, so here is the problem. On windows, a file handle to a pipe or a file (as opposed to a network socket) doesn't signal when you can read/write. This is very different from unix. For normal files you can use overlapped IO to read in the background, however for pipes you cannot. The only way to have a handle that you could add to the NSRunLoop you would have to:
1) Create an event object (CreateEvent)
2) Create a new thread, which will block reading/writing data on the pipe handle
3) When the thread gets data signal the event object
4) The main thread can wait on the event object using WaitForMultipleObjects.

This seems like it might be overkill. So I noticed that NSRunLoop has a ET_TRIGGER event type which the comments say is for the NSStream class. So I implemented NSFileHandle to use this, however, now if you call -[NSFileHandle readInBackgroundAndNotify] the program will go to 100% cpu usage.

What is the right way to use this ET_TRIGGER mode?





_______________________________________________
Gnustep-dev mailing list
Gnustep-dev@gnu.org
http://lists.gnu.org/mailman/listinfo/gnustep-dev

Reply via email to