• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: @synchronized in thread safe accessors
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: @synchronized in thread safe accessors


  • Subject: Re: @synchronized in thread safe accessors
  • From: Nick Zitzmann <email@hidden>
  • Date: Fri, 6 Feb 2009 17:19:46 -0700


On Feb 6, 2009, at 5:09 PM, Kyle Sluder wrote:

Then why bother with @synchronized? Don't fix what isn't broke.

It's one less ivar to worry about. I retro-fitted the lock to one other object I wanted to make thread-safe, only because I couldn't think of a way of doing this safely with @synchronized(), and thought I'd ask before committing. And now I'm wondering how @synthesize does atomic sets internally...


Since you're using a setter, you need to take out the lock on a
different object.  You might be able to take it out on self (a la Java
synchronization), or you might have to create a separate dummy
NSObject on which to take out the lock.  And we've now come
full-circle to the ivarLock you had in your original implementation.


Yeah, that's what I thought. But thanks for confirming this. Guess NS(Recursive)Lock still has its uses...

Nick Zitzmann
<http://www.chronosnet.com/>

_______________________________________________

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


  • Follow-Ups:
    • Re: @synchronized in thread safe accessors
      • From: Michael Ash <email@hidden>
References: 
 >@synchronized in thread safe accessors (From: Nick Zitzmann <email@hidden>)
 >Re: @synchronized in thread safe accessors (From: Kyle Sluder <email@hidden>)

  • Prev by Date: Re: @synchronized in thread safe accessors
  • Next by Date: Re: Determining if a user is logged in from a Launchd Daemon
  • Previous by thread: Re: @synchronized in thread safe accessors
  • Next by thread: Re: @synchronized in thread safe accessors
  • Index(es):
    • Date
    • Thread