• 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: Jonathan Taylor <email@hidden>
  • Date: Tue, 03 Sep 2013 14:06:57 +0100

All sounds nice, except for the fact that the parameters are being changed "behind the scenes" via the binding system. So I think I may have to implement locking on every (explicitly implemented) get/set method. That was what I had been rather hoping to avoid, but it sounds from what people are saying as if that's what I may have to do...


On 3 Sep 2013, at 13:54, Robert Vojta wrote:

> On Tue, Sep 3, 2013 at 2:39 PM, Jonathan Taylor <email@hidden> wrote:
>
> The primary instance of the object (call it MyParameters) is bound to UI elements. Changes to the UI will change the values of its properties (int/bool/double). These changes will take place on the main thread.
>
> 1. Create MyParameters instance on some object on the main thread and call it mainParameters for example.
>
> 2. All values are UI related, so, fill them on the main thread. But lock your mainParameters object before. So, on the main thread do this ...
>
> @synchronized( myObjectHoldingMyParameters.mainParameters ) {
>   myObjectHoldingMyParameters.mainParameters.X = X;
>   ...
> }
>
> 3. When you do want a copy on any other thread, do this ...
>
> MyParamaters *paramsCopy;
> @synchronized( myObjectHoldingMyParameters.mainParameters ) {
>   paramsCopy = [myObjectHoldingMyParameters.mainParameters copy];
> }
>
> ... and implement deep copy without locking. It's done via @synchronized.
>
>

_______________________________________________

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: Robert Vojta <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>)

  • Prev by Date: Re: Threadsafe copy of objective c object
  • Next by Date: Re: Threadsafe copy of objective c object
  • Previous by thread: Re: Threadsafe copy of objective c object
  • Next by thread: Re: Threadsafe copy of objective c object
  • Index(es):
    • Date
    • Thread