• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSRunLoop vs. NSThread sleep
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: NSRunLoop vs. NSThread sleep
      • From: Alastair Houghton <email@hidden>
  • Prev by Date: Re: Why is NSString->FSRef so hard?
  • Next by Date: Re: iphone SDK session duration
  • Previous by thread: Re: NSXMLParser and NSDocument
  • Next by thread: Re: NSRunLoop vs. NSThread sleep
  • Index(es):
    • Date
    • Thread