On Tue, Sep 3, 2013, at 07:29 AM, David Duncan wrote: > On Sep 3, 2013, at 5:39 AM, Jonathan Taylor > <jonathan.tay...@glasgow.ac.uk> wrote: > > > I would like to be able to take a copy of MyParameters from a thread that > > is not the main thread > > Why? > > Sure, you have a thread doing real-time video processing, but how > expensive can it be to make a copy and send it over? Audio Units > basically do this and they are just as real-time.
One of the cardinal rules of Audio Units is "Thou Shalt Not Allocate Memory On The Render Callback Thread." malloc takes a lock. Taking a lock is a great way to make you thread miss its hard-realtime constraint, which leads to glitching and potentially getting killed by the host. The typical way to do this is to perform your allocations and copies on a NON-realtime thread, and transfer ownership of data to your render thread via a lockless data structure such as a ring buffer. Your realtime thread runs for very brief periods, consuming one or two chunks of data, while your non-realtime thread runs more sporadically but for much longer periods of time, hopefully often enough to keep up with the realtime thread's consumption of data. --Kyle Sluder _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com