Re: Compile error using @synchronized on methods that return values
Re: Compile error using @synchronized on methods that return values
- Subject: Re: Compile error using @synchronized on methods that return values
- From: Jens Alfke <email@hidden>
- Date: Mon, 9 Nov 2009 10:56:18 -0800
On Nov 8, 2009, at 12:11 PM, Stuart Malin wrote:
But I suspect that from the posters comments in the post I reference
below, it isn't a bug. The problem is, you can't return up the
calling chain while being synchronized. Do whatever work it is that
needs to be performed in a synchronized way, then return whatever
result needs to be returned.
No, that's not true. It's safe to return out of an @synchronized
block. It's conceptually the same as a local C++ object whose
destructor fires whenever the block exits.
As Clark said, the warning is simply due to a bug in the compiler's
control-flow analysis — it doesn't realize that it's safe for the
function not to have a 'return' on its last line.
—Jens_______________________________________________
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