• 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: Threadsafe copy of objective c object
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Threadsafe copy of objective c object


  • Subject: Re: Threadsafe copy of objective c object
  • From: Marcel Weiher <email@hidden>
  • Date: Wed, 04 Sep 2013 17:46:03 +0200

On Sep 4, 2013, at 10:56 , Jonathan Taylor <email@hidden> wrote:

> On 3 Sep 2013, at 19:49, Marcel Weiher <email@hidden> 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 (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: Threadsafe copy of objective c object
      • From: Jonathan Taylor <email@hidden>
References: 
 >Threadsafe copy of objective c object (From: Jonathan Taylor <email@hidden>)
 >Re: Threadsafe copy of objective c object (From: Graham Cox <email@hidden>)
 >Re: Threadsafe copy of objective c object (From: Lasse Jansen <email@hidden>)
 >Re: Threadsafe copy of objective c object (From: Diederik Meijer | Ten Horses <email@hidden>)
 >Re: Threadsafe copy of objective c object (From: Jonathan Taylor <email@hidden>)
 >Re: Threadsafe copy of objective c object (From: Robert Vojta <email@hidden>)
 >Re: Threadsafe copy of objective c object (From: Jonathan Taylor <email@hidden>)
 >Re: Threadsafe copy of objective c object (From: Robert Vojta <email@hidden>)
 >Re: Threadsafe copy of objective c object (From: Jonathan Taylor <email@hidden>)
 >Re: Threadsafe copy of objective c object (From: Jeff Kelley <email@hidden>)
 >Re: Threadsafe copy of objective c object (From: Ken Thomases <email@hidden>)
 >Re: Threadsafe copy of objective c object (From: Jeff Kelley <email@hidden>)
 >Re: Threadsafe copy of objective c object (From: Kyle Sluder <email@hidden>)
 >Re: Threadsafe copy of objective c object (From: Tom Davie <email@hidden>)
 >Re: Threadsafe copy of objective c object (From: Jonathan Taylor <email@hidden>)

  • Prev by Date: Re: Subclassing a View Controller in a Storyboard
  • Next by Date: Re: Core Data Initialization
  • Previous by thread: Re: Threadsafe copy of objective c object
  • Next by thread: Re: Threadsafe copy of objective c object
  • Index(es):
    • Date
    • Thread