Re: @synchronized produces warning on messages to super
Re: @synchronized produces warning on messages to super
- Subject: Re: @synchronized produces warning on messages to super
- From: Shawn Erickson <email@hidden>
- Date: Wed, 25 Jan 2006 10:42:06 -0800
On 1/25/06, Shaun Wexler <email@hidden> wrote:
> On Jan 25, 2006, at 8:24 AM, Shawn Erickson wrote:
>
> > On 1/25/06, Jonathan del Strother <email@hidden> wrote:
> >> I found an oddity in @synchronized() behaviour - it produces warnings
> >> on any messages to super that appear after the @synchronized
> >> directive. As a trivial (and nonsensical) example :
> >>
> >> @synchronized(@"blah") {}
> >
> > Are you really synchronizing against a string constant?
>
> I don't see a problem with that,
You point out the issue with using a locally defined string constant
in the rest of your comment.
> especially if it's a unique/global object. @synchronized utilizes a small pool of mutexes which are indexed by a hash of the object pointer.
If you have the following code...
MyReader.m
@synchronized(@"BufferModificatoinMutex") { ... }
MyWriter.m
@synchronized(@"BufferModificatoinMutex") { ... }
The string constants used above have different addresses because each
lives in a different object file so each block of code is not
synchronizing against the same mutex which is likely what someone
would assume at first pass over the code. ...hence my question.
-Shawn
_______________________________________________
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