gnustep-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSStreams and runloops and polling


From: Jeremy Bettis
Subject: NSStreams and runloops and polling
Date: Thu, 13 Apr 2006 14:24:36 -0500
User-agent: Thunderbird 1.5 (Windows/20051201)

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?







reply via email to

[Prev in Thread] Current Thread [Next in Thread]