Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[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]



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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

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>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.