Re: Data from thread to NSView, efficiently
Re: Data from thread to NSView, efficiently
- Subject: Re: Data from thread to NSView, efficiently
- From: Jacob Engstrand <email@hidden>
- Date: Wed, 18 Jul 2007 10:33:50 +0200
On 18 jul 2007, at 07.41, Chris Hanson wrote:
On Jul 17, 2007, at 9:45 AM, Jacob Engstrand wrote:
And, of course, if the producer is "too fast" for the consuming
main thread, it should accumulate batches of data and send them of
to newDataAvailable: in chunks. Or, if you _know_ there will be
data and so won't loose performance by polling, let the Producer
put the data in a shared NSArray, and set an NSTimer to let the
main thread harvest the shared NSArray every now and then.
Delivering data _to_ a thread can be done with much less overhead
(very simply using an NSArray to share the data between the
threads), using MPWaitOnSemaphore() and MPSignalSemaphore().
I think you mean NSConditionLock rather than an MPSemaphore above. :)
Producer-consumer by means of a shared work queue is a standard
pattern in multithreaded programming. You should need zero or at
most one invocation of the -[NSObject
performSelectorOnMainThread:withObject:waitUntilDone:] method.
No, I actually meant to use MPSemaphore above. Although
NSConditionLock is a perfectly good Cocoa alternative. Potato Tomato. :)
jak
_______________________________________________
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