Re: Synchronizing Thread Execution
Re: Synchronizing Thread Execution
- Subject: Re: Synchronizing Thread Execution
- From: Alastair Houghton <email@hidden>
- Date: Tue, 5 Dec 2006 19:02:37 +0000
On 5 Dec 2006, at 15:25, Scott Ribe wrote:
Note that you'd want to make sure that this string is unique within
your code
Actually, if it really just needs a pointer, then:
static int foo;
...
@synchronized(&foo)
...
Problem is, even though the current implementation just goes off
the pointer
value, the documentation does state " The @synchronized() directive
takes as
its only argument any Objective-C object...". But then a couple of
paragraphs later it uses the selector _cmd, and selectors are *NOT*
Objective-C objects.
AFAIK it does NSStringFromSelector(_cmd), which returns an NSString,
which
*is* an Objective-C object.
Your point---that you shouldn't rely on @synchronized() just working
on the
basis of a pointer---is, however, very valid. If you rely on that,
you might
break on any future ObjC implementation (maybe even the 64-bit one
that's
coming in Leopard).
Kind regards,
Alastair.
--
http://alastairs-place.net
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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