Re: Getting mouse clicks when the main loop is busy
Re: Getting mouse clicks when the main loop is busy
- Subject: Re: Getting mouse clicks when the main loop is busy
- From: Charles Srstka <email@hidden>
- Date: Mon, 11 Nov 2013 13:18:55 -0600
On Nov 11, 2013, at 11:59 AM, Kyle Sluder <email@hidden> wrote:
> Shorthand for "initializer or one of the methods called by it, like -readFromFileWrapper:ofType:".
>
> My point is that it takes a lot of work to subvert NSDocument's understanding of when and how a document is loaded, and simply forking off a background operation to load your document is NOT going to play nice with that.
>
> NSDocument invokes -readFromURL:… within a file coordination block. If you bail out of that early and read your document contents in a background operation, you will erroneously yield the document back to whatever reacquirer is waiting for it—whether in your app or another. This can cause corruption as another app believes it has exclusive write access to your document’s contents just as your background op gets around to reading it.
Since the format is non-editable, I'm not terribly worried about that. You create it once and that is it.
> If you instead try to invoke your own file coordination from the background operation, you will very likely deadlock against NSDocument’s own coordinated access.
>
> There is no winning here. Load your document when and where NSDocument expects you to load your document. Enroll in background document loading by returning YES from +canConcurrentlyReadDocumentsOfType:. Put up progress UI before loading the document, and take it down when it’s done.
That precludes one from lazily loading the file contents into the UI, and is not appropriate for every type of app. Suppose you have an app that might need to open multi-GB files. Loading the whole thing into memory is not going to work — you need to be able to lazily load from the disk, or else performance is going to be terrible.
Charles
_______________________________________________
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