Re: Surprising entanglement of UI lock during fetch request in background thread (NSViewHierarchyLock/MOC locking deadlock).
Re: Surprising entanglement of UI lock during fetch request in background thread (NSViewHierarchyLock/MOC locking deadlock).
- Subject: Re: Surprising entanglement of UI lock during fetch request in background thread (NSViewHierarchyLock/MOC locking deadlock).
- From: Michael Ash <email@hidden>
- Date: Sun, 22 Feb 2009 18:33:10 -0500
On Sun, Feb 22, 2009 at 3:46 PM, Luke Evans <email@hidden> wrote:
> My discovery (and life is full of them, so nothing particularly unusual
> here) is that the practicality of doing the locking appears to 'tip over' if
> you have binding to your Core Data. I have my main thread, and one
> background thread trawling for files - both scrupulously locked on the MOC
> around _any_ access, i.e. even reading a property.
No you don't. You're locking around any *explicit* access to a
property. Meanwhile your implicit accesses due to bindings are going
unlocked, and your code fails, hard.
It's a basic tenet of multithreading. If you're taking an unsafe
datastructure, and making it safe by synchronizing all accesses with
locks, you *cannot* give *any* references to that data structure to
outside code.
Bindings will not follow your locking protocol, so you can't let them
touch your context with this approach.
Mike
_______________________________________________
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