Re: I think I screwed up Core Data multi-threading rules.
Re: I think I screwed up Core Data multi-threading rules.
- Subject: Re: I think I screwed up Core Data multi-threading rules.
- From: Quincey Morris <email@hidden>
- Date: Sat, 25 Feb 2017 16:57:43 -0800
- Feedback-id: 167118m:167118agYYG0F:167118sezLv_UtzB:SMTPCORP
On Feb 25, 2017, at 14:58 , Daryle Walker <email@hidden> wrote:
>
> I thought the entire AppKit, which includes NSDocument, runs only on the main thread. The exceptions are methods that specially state that they have a multi-threaded mode.
Much stuff in AppKit must be called on the main thread, yes, and anything that affect the UI presentation we assume to require the main thread. And yes, many more recent APIs have a background-thread operational mode for (usually) parts of a larger functional process. However, there’s a third category, of stuff that does not apparently have any thread requirements beyond the basic need for thread safety of mutable data references.
The fact that the documentation for this save method explicitly states the need to invoke the completion handler on the main thread is a hint that the save method might be in this third category — not have any thread-related requirements of its own.
In addition, since it’s so easy to invoke a handler on the main thread, I’d say it’s safer to do so, than to rely on an assumption, however plausible.
_______________________________________________
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