Re: NSRunLoop looping more than once?
Re: NSRunLoop looping more than once?
- Subject: Re: NSRunLoop looping more than once?
- From: Chris Kane <email@hidden>
- Date: Thu, 20 Mar 2003 13:09:13 -0800
On Tuesday, March 18, 2003, at 19:07, John Anderson wrote:
But now I have to ask: How can NSLog() change a runLoop's state???
NSLog(), or any function or method call for that matter, may directly
or indirectly do something which removes from or adds to the run loop.
For example (an actual historical example, which could always happen
again), NSLog() might use NSCalendarDate formatting to format the
banner or proem or preamble on the log message. The formatting might
need to get the default time zone from NSTimeZone. Getting the default
time zone (say, on first call) might cause NSTimeZone to want to know
when that changes, so it registers itself for a distributed
notification. For distributed notifications to come in, an internal
port to receive the notifications must be installed in the run loop.
QED
Actually using a "real" source to poke the run loop into returning
is the less-polling way to do things.
I am writing a "real-time" framework for Cocoa. So, I do not see how
I am going to avoid using at least one repeating NSTimer to drive the
code. Perhaps, the "minimal-polling" way to do "real-time" is to have
only one NSTimer driven runLoop and let it "poke" the rest of the code
via "real" sources.
I don't see how it follows from "real-time" that you need to use an
NSTimer. Indeed, because it executes at very high priority, real-time
code should execute as little and quickly as possible. Message passing
between threads would be a better (probably) way to cause the run loop
to exit, using a run-once method.
Chris Kane
Cocoa Frameworks, Apple
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.