On Sep 4, 2013, at 10:56 , Jonathan Taylor <jonathan.tay...@glasgow.ac.uk> 
wrote:

> On 3 Sep 2013, at 19:49, Marcel Weiher <marcel.wei...@gmail.com> wrote:
>> Unless there is some dire reason not to do this, I would make a copy on the 
>> main thread every time the UI changes, and stash that copy somewhere the 
>> worker thread can access it easily.
> 
> That's a really good plan, I realised that last night. I had been stuck 
> thinking about kind of the opposite approach (make a copy on each invocation 
> of the processing algorithm), but this makes a lot of sense. How does this 
> sound:
> 
> When the UI leads to changes in the (mutable) primary object I'll make a copy 
> stored in an immutable shadow object (from the main thread). 
> Whenever the algorithm is invoked (from a secondary thread in response to 
> receipt of a frame) I retain the immutable shadow object and pass this 
> pointer to the algorithm.

Sounds pretty good to me.  I’d probably stash it in an instance variable.  In a 
sense, this is a variant of the immutability that Ian and Jens suggested:  
create a copy that you won’t mutate.

> From what Jens and others have said, it's my understanding that if the 
> property for the (immutable) shadow object is designated atomic/retain then I 
> wouldn't need a mutex to access it. 

Yep.

Marcel

_______________________________________________

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

Reply via email to