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: Fritz Anderson <email@hidden>
- Date: Fri, 08 Nov 2013 12:04:17 -0600
On 8 Nov 2013, at 11:16 AM, Graham Cox <email@hidden> wrote:
> What’s the proper way to do this? I *can* open the file on another thread and let the main thread run normally, and that’s fine, but I do need a solution that works for when the file is opened on the main thread.
With the humblest intention in the world, and admitting I don't know your use case…
You seem to suggest that "opening the file on the main thread" might be unavoidable. Is this because the process of identifying, opening, reading, processing, and closing the file might be confined to a third-party library that isn't thread-safe? I can't imagine another way you couldn't pass a path, URL, or file descriptor into a thread. (I have a limited imagination.)
If you're not in that situation, I suggest doing whatever you prudently can to load the file on a background thread every time. It factors your app by cutting your code paths in half, and you don't have to rely on cooperative multitasking to keep up a responsive UI. If you're just filling a buffer or interpreting a stream from a file, and don't need to display partial results other than progress, you're in about the least-hard thread-confinement situation you can have.
That's my esthetic. There are excellent developers who use a cooperative runloop with good results.
— F
_______________________________________________
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