Re: main loop and idle function
Re: main loop and idle function
- Subject: Re: main loop and idle function
- From: Chris Kane <email@hidden>
- Date: Sat, 23 Feb 2002 17:58:12 -0800
On Saturday, February 23, 2002, at 02:22 PM, Lance Bland wrote:
On Saturday, February 23, 2002, at 04:43 PM, Jay Kuri wrote:
You set a timer to fire every so often (perhaps every tenth of a
second, or such) and call your idle-method... that should probably do
what you want.
If NSRunLoop allowed (or documented) the ability to add run loop modes
and set priorities then that would be even better. I think the only
realistic mode option is NSDefaultRunLoopMode, which is not an idle
mode.
If adding modes and setting mode priorities is documented I'd like to
hear about that.
Priorities on run loop modes doesn't make any sense, since at most one
mode is being monitored at any one time (on a particular thread; and
each thread has a distinct set of modes, even if they have the same
names) -- there's no competition between modes for a priority to resolve.
Adding modes is easy -- just register your input source (say, timer) in
whatever string mode name you like, and that creates the mode
implicitly. However, only you can run the run loop in a private mode,
since only you know about the name of it. Private modes are only useful
for short-period specific situations.
A short-period repeating timer, like 0.1 seconds isn't the best
solution, because an app will spin, though slowly, and chew a percentage
of the cpu, unless you truly do need to check something that often.
Idle notifications via the notification queue are a somewhat better
solution, doing a bit of work each time you get one, and keep posting
the notification as long as you have more work to do (or a series of
one-shot timers in the same way, instead of notifications). This came
up just recently on either this list or the OmniGroup
(www.omnigroup.com) macosx-dev list, so list archives have more
information.
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.