On Mar 8, 2012, at 4:15 PM, Quincey Morris wrote:
> Well, slap my head if I'm missing your intention, but I don't see how having
> an *atomically* safe NSMutableArray helps at all. As soon as anyone in any
> thread writes:
>
> for (NSInteger i = 0; i <= atomicallySafeArray.count; i++) {
> id object = [atomicallySafeArray objectAtIndex: i];
> ...
> }
>
> or any such construct that contains 2+ references to the array that might see
> a different state of the array over time, then the code is broken and not
> thread safe. This is also broken:
>
> for (id object in atomicallySafeArray)
> …
>
> for the separate but related reason that fast enumeration will fail if the
> array mutates.
>
> Also, implementing the accessors won't solve either of these problems.
>
> Thread safety does *not* come from atomicity. Conversely, in many cases
> atomicity has no value whatsoever -- because thread safety is what's really
> required.
For those two examples, it seems like having the default accessor return an
immutable array via copy would solve the issue.
Charles
_______________________________________________
Cocoa-dev mailing list ([email protected])
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 [email protected]