• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Data from thread to NSView, efficiently
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Data from thread to NSView, efficiently (From: "William Zumwalt" <email@hidden>)
 >Re: Data from thread to NSView, efficiently (From: Jacob Engstrand <email@hidden>)
 >Re: Data from thread to NSView, efficiently (From: Chris Hanson <email@hidden>)

  • Prev by Date: Re: creating a controller class
  • Next by Date: Re: Bonjour and Airport
  • Previous by thread: Re: Data from thread to NSView, efficiently
  • Next by thread: Can reviewUnsavedDocuments ever NOT be cancelled?
  • Index(es):
    • Date
    • Thread