• 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: Surprising entanglement of UI lock during fetch request in background thread (NSViewHierarchyLock/MOC locking deadlock).
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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: Chris Hanson <email@hidden>
  • Date: Sat, 21 Feb 2009 11:39:02 -0800

On Feb 20, 2009, at 11:57 AM, Luke Evans wrote:

My app has a table whose content shows files. The files that get shown here are stored in Core Data, the table is bound to the Core Data model to show the appropriate stuff.
A background thread is started to spider through the file system looking for appropriate files. When a new candidate file is spotted, the managed object context is locked, and the file is added to the 'store'.

This is the problem. Bindings are not thread-safe. That is, bindings don't take a lock before access. Thus even though your code is locking the managed object context that is shared between the threads, AppKit isn't, and therefore you'll run into all sorts of consistency issues.


You should probably pursue a context-per-thread approach for this kind of use, where the contexts share a persistent store coordinator. Then when your background thread wants to tell the main thread about something, it can just pass it an object ID that the main thread can use to get the object in its own context.

  -- Chris

_______________________________________________

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


References: 
 >Surprising entanglement of UI lock during fetch request in background thread (NSViewHierarchyLock/MOC locking deadlock). (From: Luke Evans <email@hidden>)

  • Prev by Date: Re: Window Animation with setFrame:display:animate: Flickers
  • Next by Date: Re: Memory Management and @synthesized accessors
  • Previous by thread: Re: Surprising entanglement of UI lock during fetch request in background thread (NSViewHierarchyLock/MOC locking deadlock).
  • Next by thread: Core Data reads xml store value @" " as @""
  • Index(es):
    • Date
    • Thread