• 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: Accessing array in thread safe way
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Accessing array in thread safe way


  • Subject: Re: Accessing array in thread safe way
  • From: Quincey Morris <email@hidden>
  • Date: Thu, 08 Mar 2012 14:57:21 -0800

On Mar 8, 2012, at 14:29 , Charles Srstka wrote:

> For those two examples, it seems like having the default accessor return an immutable array via copy would solve the issue.

It wouldn't solve, e.g., the possibly inconsistency between 'array.count' and a subsequent reference, unless it was coded to keep a "consistent" local reference to the copy of the array, in which case you'd want the copy to be explicit in the API so that a reader of the code would be aware, and that would be a non-atomic-level approach anyway.

I also wanted to point out that there's another defect in Tamas's code: it needs an explicit atomic 'copy' implementation, and therefore an explicit atomic 'mutableCopy' implementation. And who knows what else …

I'm begging ya to forgeddaboudit. The atomicity solution is a fantasy**. You can't solve thread safety at that level.



** However, we don't know the scenario Tamas wrote the code for. It's possible atomicity solved whatever issue he was facing, that wasn't general thread safety. It's also possible he didn't solve anything, but just changed a likely-to-cause-a-crash bug into a impossible-to-crash-but-likely-to-cause-a-rare-and-subtle-but-almost-impossible-to-debug-error bug.

_______________________________________________

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: Accessing array in thread safe way
      • From: CoGe - Tamas Nagy <email@hidden>
    • Re: Accessing array in thread safe way
      • From: Charles Srstka <email@hidden>
References: 
 >Accessing array in thread safe way (From: "Jan E. Schotsman" <email@hidden>)
 >Re: Accessing array in thread safe way (From: Charles Srstka <email@hidden>)
 >Re: Accessing array in thread safe way (From: "Jan E. Schotsman" <email@hidden>)
 >Re: Accessing array in thread safe way (From: CoGe - Tamas Nagy <email@hidden>)
 >Re: Accessing array in thread safe way (From: Charles Srstka <email@hidden>)
 >Re: Accessing array in thread safe way (From: CoGe - Tamas Nagy <email@hidden>)
 >Re: Accessing array in thread safe way (From: Quincey Morris <email@hidden>)
 >Re: Accessing array in thread safe way (From: Charles Srstka <email@hidden>)

  • Prev by Date: Re: Accessing array in thread safe way
  • Next by Date: Re: @-directives
  • Previous by thread: Re: Accessing array in thread safe way
  • Next by thread: Re: Accessing array in thread safe way
  • Index(es):
    • Date
    • Thread