• 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: Core Data & threads [re: Ping: Look for hints for "nested transaction" problem with Core Data]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Core Data & threads [re: Ping: Look for hints for "nested transaction" problem with Core Data]


  • Subject: Re: Core Data & threads [re: Ping: Look for hints for "nested transaction" problem with Core Data]
  • From: Pierre Chatelier <email@hidden>
  • Date: Sat, 17 Mar 2007 12:13:13 +0100

If you suspect the objects have already been fetched by someone else (or yourself previously), use -objectWithID: or - objectRegisteredForID: instead of -executeFetchRequest:
That's right, but here is the test case I am thinking about :
I have two threads A and B, each one owning their own managed object context Ma and Mb
thread A computes objects o1, o2, o3, ..., [save], o7, o8
thread B computes objects o11, o7
Since o7 has not been saved in thread A, it has a temporary objectID. So, I cannot fetch it in Mb, neither with executeFetchRequest, nor objectWithID.


Is there a solution in this case ?
The save-then-notify-others idiom works quite well with multiple threads in Core Data.
I think it would be too expensive to call save: for each object, because it is many of small objects.
So, yes, I could recompute o7 in thread B, but it is not optimal. If save occurs every two minutes, this may be 2 minutes of computation lost.


Regards,

Pierre Chatelier

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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: 
 >Core Data & threads [re: Ping: Look for hints for "nested transaction" problem with Core Data] (From: Ben Trumbull <email@hidden>)
 >Re: Core Data & threads [re: Ping: Look for hints for "nested transaction" problem with Core Data] (From: Pierre Chatelier <email@hidden>)
 >Re: Core Data & threads [re: Ping: Look for hints for "nested transaction" problem with Core Data] (From: Ben Trumbull <email@hidden>)
 >Re: Core Data & threads [re: Ping: Look for hints for "nested transaction" problem with Core Data] (From: Pierre Chatelier <email@hidden>)
 >Re: Core Data & threads [re: Ping: Look for hints for "nested transaction" problem with Core Data] (From: Ben Trumbull <email@hidden>)

  • Prev by Date: Re: capturing a double-click on a control
  • Next by Date: Target-Action in NSTableView
  • Previous by thread: Re: Core Data & threads [re: Ping: Look for hints for "nested transaction" problem with Core Data]
  • Next by thread: How to implement NSSecureTextField to display bullets instead string.
  • Index(es):
    • Date
    • Thread