Re: High Level Toolkit -- is it obsolete or not?
Re: High Level Toolkit -- is it obsolete or not?
- Subject: Re: High Level Toolkit -- is it obsolete or not?
- From: Nick Zitzmann <email@hidden>
- Date: Tue, 23 Feb 2010 15:49:04 -0700
On Feb 23, 2010, at 3:30 PM, Joel May wrote:
> Question about NSThread seeing how GetKeys(), etc. are not thread safe: If I increase the priority of the main thread, then move the view draw cgcontext updates to a lower priority thread, is that a good idea? Will increasing the priority of the main thread reduce latency for getting the keypress and mouse inputs?
Two words: Schrödinger's Cat. :) You won't know until you observe.
> Does the OS actually honor this request?
Yes, you can change a running thread's priority using NSThread. I've never had to change a main thread's priority, though.
> Can I take the drawRect requests and pass the rectangle to the lower thread and update the view there?
No; in all classes except for NSButton and NSProgressIndicator (and any other classes that use the old, private heart-beat API), you do threaded drawing by turning on concurrent drawing in the view. You can only do this in Snow Leopard & later, and it's not a good idea to try this unless you know for a fact that it supports thread-safe drawing. IKImageBrowserView, for example, will freeze if you turn on concurrent drawing.
Also, it's been my experience that concurrent drawing is currently useless if you need to flush multiple updates to multiple views at once, because concurrent drawing changes flush immediately instead of at the same time as everything else, which could look a little strange. I have a bug open on this...
> Is this crazy?
Maybe.
> Non-thread safety of GetKeys() and Buttons(): If I call these in the wrong thread, can they crash the application? Or is the damage limited to erroneous results?
The results are most likely undefined and could change between OS releases or even individual trials. I wouldn't try if the header says it's not thread-safe.
Nick Zitzmann
<http://www.chronosnet.com/>
_______________________________________________
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