• 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: Chris Hanson <email@hidden>
  • Date: Tue, 17 Jul 2007 22:41:10 -0700

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.

 -- Chris

_______________________________________________

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


  • Follow-Ups:
    • Re: Data from thread to NSView, efficiently
      • From: Jacob Engstrand <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>)

  • Prev by Date: Re: creating a controller class
  • Next by Date: Re: creating a controller class
  • Previous by thread: Re: Data from thread to NSView, efficiently
  • Next by thread: Re: Data from thread to NSView, efficiently
  • Index(es):
    • Date
    • Thread