Re: How to cancel a loading document in NSDocument's readFromURL:ofType:error method ?
Re: How to cancel a loading document in NSDocument's readFromURL:ofType:error method ?
- Subject: Re: How to cancel a loading document in NSDocument's readFromURL:ofType:error method ?
- From: Kyle Sluder <email@hidden>
- Date: Thu, 09 Feb 2012 19:32:20 -0800
On Feb 9, 2012, at 7:08 PM, Jeffrey Oleander <email@hidden> wrote:
>
> I don't get it. I though with OS X one of the great
> benefits was finally having pre-emptive multi-processing
> instead of co-operative multi-processing.
>
> Sure, when the user clicks "Cancel" it's an "event",
> it gets stuffed on an event queue, the wheels grind
> round and round and eventually that event gets popped
> off of the queue and paid attention to. But then...
> then the event processor, the action, should see that
> it needs to interrupt the file transfer cold,
> as close to immediately as possible, the buffers
> that were being used for the transfer freed, and
> control returned to the regularly scheduled programming.
> Neat. Sweet. And at least somewhat close to immediate
> in user terms. Not, Eyeore style... "ohhh, maybe...
> some... day..., maybe after it gets done filling
> the next buffer or 10... we may think about getting
> around to doing something about it."
I think you misunderstand "preemptive multitasking" to imply more power than it actually provides.
In a vast majority of modern application programming situations, it isn't safe to just kill a background thread when the user hits Cancel. It might be in the middle of I/O (reading a document from disk); it might be holding critical resources (such as, say, the malloc lock); other threads may be waiting for it to provide important data (the NSError object explaining why loading failed).
If you wish for an environment where such things are possible, you might consider taking a contracting position working on formally-proven systems.
--Kyle Sluder
_______________________________________________
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