On Apr 10, 2014, at 5:29 AM, Roland King wrote:

> On 10 Apr, 2014, at 6:20 pm, Dave <d...@looktowindward.com> wrote:
> 
>> I was confused by this:
>> 
>>> It also doesn't make sense to synchronize on the myDict object.  That's 
>>> what is in flux.  You should synchronize on "self", the object which owns 
>>> and manages myDict. 
>> 
>> Surely as long as every access to the dictionary is @synchronized to the 
>> same entity it’s fine?

> Yes but that's not what he's doing, he's not mutating the dictionary (even 
> though it's mutable), he's replacing one dictionary with another one. So the 
> point of synchronizing on self in that case is to prevent the dictionary 
> being swapped out between calls. 

Between or even during.  Correct.  And furthermore, when the dictionary is 
swapped out, the old one is presumably released.  If that was the last 
reference, then it would be deallocated.  Synchronizing on an object in one 
thread that may be deallocated in another is a very bad idea.

Regards,
Ken


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to