Re: Threadsafe copy of objective c object
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:34:20 +0100
Ah. In my original email I didn't explain *why* it is that "ideally I would like to make the copy on a thread other than the main thread". The algorithm is doing real-time video processing, and I very much want to avoid holding up anything in that code path by synchronizing with the main queue. Past experience has shown that that does lead to glitches I am keen to avoid. So, while I'm a big fan of such constructions, I'm deliberately trying to avoid that here.
Serializing access to MyParameters will work, it's just a shame that there isn't such a tidy way of achieving that...
On 3 Sep 2013, at 14:18, Robert Vojta wrote:
> Then this should be enough ...
>
> - (MyParameters *)copyParameters {
> __block MyParameters *parameters;
> dispatch_sync( dispatch_get_main_queue(), ^{
> parameters = [myObjectHoldingParameters.parameters copy];
> });
> return parameters;
> }
>
> ... if all your parameters object properties are set on the main thread only.
>
_______________________________________________
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