NSRunLoop vs. NSThread sleep
NSRunLoop vs. NSThread sleep
- Subject: NSRunLoop vs. NSThread sleep
- From: Eric Hermanson <email@hidden>
- Date: Tue, 28 Apr 2009 19:57:38 -0400
Hello,
When implementing the while-loop in the main function of an NSThread,
is it correct to assume it is more efficient on the operating system
to run the current run-loop until a specified date rather than just
use NSThread sleepUntilDate to obtain the delay? I ask because I
don't really need a formal run loop or special input source as I'm
just checking a shared queue for data (and the delay is to allow the
thread to gracefully exit). So it's simpler to code just the NSThread
sleep, however, I am guessing that will cause me context switching
performance issues and I'd be better off using the NSRunLoop?
Finally, is it acceptable to use the NSThread's cancelled/isCancelled
mechanism to check for the thread-exit hint, rather than set/check a
global variable in the NSThread threadDictionary (as Apple's
documentation shows)?
Thank You,
- Eric
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden