• 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
Re: Endless loop but only with release build
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Endless loop but only with release build


  • Subject: Re: Endless loop but only with release build
  • From: Bill Bumgarner <email@hidden>
  • Date: Sat, 30 Sep 2006 10:30:03 -0700

On Sep 30, 2006, at 9:02 AM, Antonio Nunes wrote:
Could this be a compiler bug, or is this not a good way to handle states across threads? (If I don't wait for _isConverting to become NO in windowWillClose then the app may crash when closing a window, hence the need for this loop.) Anybody an idea why this code above works fine in debug build and loops endlessly in release build?

The compiler is likely optimizing a loop with no statements in its body. Possibly, a bug, even?


However, yes, this is not a good way to handle state across threads. It busy-waits the CPU, eating tons and tons of CPU spinning madly waiting for something to be done -- and slowing down the task that is running in the other thread (and everything else on the system). If this is a Cocoa app and you are busy waiting from the main thread, you have also rendered the application completely unresponsive.

For non-Cocoa apps, use a lock.

For Cocoa, use one of the methods that performs a selector (a method) on the main thread to pass notification between the threads.

b.bum

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Endless loop but only with release build
      • From: Antonio Nunes <email@hidden>
References: 
 >Endless loop but only with release build (From: Antonio Nunes <email@hidden>)

  • Prev by Date: Re: How to draw Text inside a NSImage?
  • Next by Date: Re: Endless loop but only with release build
  • Previous by thread: Endless loop but only with release build
  • Next by thread: Re: Endless loop but only with release build
  • Index(es):
    • Date
    • Thread