Re: Adding custom inputs to NSRunLoop
Re: Adding custom inputs to NSRunLoop
- Subject: Re: Adding custom inputs to NSRunLoop
- From: Andreas Monitzer <email@hidden>
- Date: Wed, 26 Sep 2001 13:43:56 +0200
On Wednesday, September 26, 2001, at 12:58 , Malte Tancred wrote:
Yes, but how do I implement a port? I can't find
anything in the API that allows your own port subclass
to report it's status to the run loop nor get a slice
of the loop.
Perhaps it's my picture of what a run loop is that's
scewed, but as I understand, each cycle of the run
loop involves checking the states of it's input sources.
If they're 'ready' they're 'fired'; an NSTimer invokes its
action and an NSPort sends its delegate is sent the
appropriate -handleMachMessage: or -handlePortMessage:
message.
My perception of the run loop is that it to some
degree resembles the concept of the select() system
call, with goodies added.
So, if I want to implement a subclass to NSPort, is there
a message sent from the run loop telling my port to
handle the input?
If NSRunLoop would use polling for all events, it would constantly suck up
the CPU, even in the background. AFAIK NSRunLoop is implemented via select(
), which means it needs a file descriptor.
I don't know how to do it in Foundation, but you can convert a file
descriptor to a CFSocket (CFSocketCreateNative or something like this) and
add this one to the current CFRunLoop (there's a method for converting an
NSRunLoop to a CFRunLoop).
andy
--
Description forthcoming.