• 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
pointer assignment inherently atomic ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

pointer assignment inherently atomic ?


  • Subject: pointer assignment inherently atomic ?
  • From: "Chase" <email@hidden>
  • Date: Fri, 10 Aug 2007 19:52:49 +0000


can anyone help me with my question of the day:

are pointer assignments inherently atomic ?


i have an NSMutableArray that gets periodically rebuilt in a background thread.
the main thread or any of several other threads may want read access to it at any time.


when i rebuild it in the background thread, i am actually building a new, separate array and once i'm done i swap in the new one for the old one:

oldarray = realarray;
realarray = newarray; // the swap
[oldarray release];


now i could put locks around every place where i read it or write to it (lots of code clutter in this particular case), but i'm thinking that it may not be necessary since the swap will ultimately boil down to (i think) a single, indivisible cpu instruction (....maybe).


is this a fair assumption?

note that i haven't had any crashes or bugs related to this so far (over the course of several weeks of development), but i'm worried it may just be luck.

any input would be great.

thanks.

- chase



_______________________________________________

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: pointer assignment inherently atomic ?
      • From: Bill Bumgarner <email@hidden>
    • Re: pointer assignment inherently atomic ?
      • From: Uli Kusterer <email@hidden>
    • Re: pointer assignment inherently atomic ?
      • From: Alastair Houghton <email@hidden>
    • Re: pointer assignment inherently atomic ?
      • From: Scott Ribe <email@hidden>
  • Prev by Date: Bill Abt is out of the office.
  • Next by Date: Re: format for editable vector graphics exchange
  • Previous by thread: Bill Abt is out of the office.
  • Next by thread: Re: pointer assignment inherently atomic ?
  • Index(es):
    • Date
    • Thread