Re: dispatch queues and KVO?
Re: dispatch queues and KVO?
- Subject: Re: dispatch queues and KVO?
- From: Quincey Morris <email@hidden>
- Date: Tue, 15 Oct 2013 14:35:32 -0700
On Oct 15, 2013, at 14:08 , Rick Mann <email@hidden> wrote:
> The other thing to keep in mind is synchronization. Always updating the property via the main queue is a good way to ensure there are no concurrency issues.
Unfortunately, it's not quite as simple as that. *Updating* the property on the main queue ensures that there are no concurrency issues between multi-threaded *updates*, it doesn't ensure thread safety for multi-threaded *accesses*.
Depending on the circumstances, atomicity (i.e. an atomic property) might be all that's needed in this case. If so, the main-thread dispatch thing isn't needed anyway. Otherwise, a more comprehensive thread safety strategy is required.
On Oct 15, 2013, at 13:43 , Todd Heberlein <email@hidden> wrote:
> self.some_ivar = some_value;
Todd, you wrote "some_ivar", but you coded as if "some_property". If you really meant a property, see above. If you really meant an ivar, then you should keep in mind that [in general] it's architecture-dependent whether a variable store is atomic in a multi-CPU environment. It may well be so for all CPU architectures supported by OS X and iOS at the moment, but it's something you should keep in mind generally. (It wasn't true, IIRC, for the PPC architecture, not for all combinations of variable size and alignment.)
Similarly, some source code ivar stores (e.g. to a __weak variable) may not be atomic with ARC, because there's a run-time function call involved, but I can't say I've looked into that aspect of it.
_______________________________________________
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