• 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
[CORE DATA] multithreading
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[CORE DATA] multithreading


  • Subject: [CORE DATA] multithreading
  • From: Aurélien Hugelé <email@hidden>
  • Date: Mon, 27 Feb 2006 15:35:29 +0100

Hi list!

I've read almost all posts on this list about core data, but subtle details still puzzle me. I hope someone can clarify things (again?)

When i launch my app, currently, a spotlight query is started (in the main thread) to try to import new emails (all new emails since date: initialDate)
Then, when i know the new emails file pathes, i parse them and import their informations (sender, recipients, subject etc...) in a SQLite Core Data database.


The problem here is that importing of my datas is quite slow, and since everything is done in the main thread, as soon as the app is launched, the UI is not immediatly responsive.
What is blocking the UI (about 10-15 second on a fast G5) is:
1/ a fetch to avoid reimporting an already imported email (each email has a uniqueId in its header, so the fetch has a "uniqueId IN { .. .. .. ..}" predicate type),
2/ several fault firing slowness that i have optimized as most as i can, and these optimizations are already efficient (for exemple, i prefetch some relationships to the sender and recipients since they are going to be modified when i'll add a new email and save about 2-3 min for a large import)


Now, i want to thread the import phase to keep the UI non blocking.

Shortly, i have respected the "rules": one MOC per thread, sharing one PSC. Never passed NSManagedObjects between threads, but use objectID instead.

But i have some problem to understand if I have to synchronize both MOC manually or not ? i mean, should i insert in the main thread moc (using [moc1 insertObject:[moc1 objectWithID:objectId]]) the objects i inserted in the threaded moc (ie moc2, using insertNewObjectForEntityForName:inManagedObjectContext:) ? from what i have read on this list, i have to synchronize mocs, nothing is done for me.

what happens if i delete an object in the threaded moc (moc2) ? how should i synchronize moc1 ? i suppose i can not use objectWithID: because the object has been deleted!?

should i perform moc save: twice ? once in each thread ?

wouldn't be clever to use notifications ?

I think BackgroundFetching sample code is a great start, but only explains how to do background fetching... nothing a little bit more complex :)

Thanks!

Aurélien _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Why is NSFontManager lying to me ?
  • Next by Date: Help in Sketch Example
  • Previous by thread: Re: Why is NSFontManager lying to me ?
  • Next by thread: [CORE DATA] multithreading
  • Index(es):
    • Date
    • Thread