Re: Endless loop but only with release build
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