• 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: Migrating changed objects between contexts
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Migrating changed objects between contexts


  • Subject: Re: Migrating changed objects between contexts
  • From: Keary Suska <email@hidden>
  • Date: Wed, 2 Dec 2009 09:28:37 -0700

On Dec 1, 2009, at 11:05 PM, Jim Thomason wrote:

> So. First off, is there some way I can just leave the existing code in
> there that uses the same context and just locks it in the secondary
> thread? The second thread basically consisted of:
>
> -(void) makeGraph {
>  NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
>  [[document managedObjectContext] lock];
>  //big honkin' code to make the graph
>  [[document managedObjectContext] unlock];
>  [pool release];
> }
>
> But since both the second thread and the main thread were trying to
> load up the same object at once, it deadlocked. Is there some other
> bit of locking magic I can add in to do it?

It shouldn't deadlock. The doc for -lock says: "If you lock (or successfully tryLock) a managed object context, the thread in which the lock call is made must have a retain until it invokes unlock. If you do not properly retain a context in a multi-threaded environment, this will result in deadlock." Did you heed it?

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"

_______________________________________________

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: 
 >Migrating changed objects between contexts (From: Jim Thomason <email@hidden>)

  • Prev by Date: Re: Control Appearance on Textured Window Sheet (Solution)
  • Next by Date: Re: Application crashing on iPod Touch, not on iPhone
  • Previous by thread: Migrating changed objects between contexts
  • Next by thread: Re: Migrating changed objects between contexts
  • Index(es):
    • Date
    • Thread