Re: Accessing array in thread safe way
Re: Accessing array in thread safe way
- Subject: Re: Accessing array in thread safe way
- From: Sean McBride <email@hidden>
- Date: Tue, 06 Mar 2012 17:49:44 -0500
- Organization: Rogue Research Inc.
On Tue, 6 Mar 2012 20:51:10 +0100, Jan E. Schotsman said:
>I have an array of progress values (number objects) for subprojects,
>from which I calculate the overall progress .
>The array is an atomic property of the project class.
>
>Is it safe to access this array from multiple threads, using methods
>like objectAtIndex and replaceObjectAtIndex?
If you're talking about replaceObjectAtIndex, then you're talking about an NSMutableArray. It is not magically thread safe; you'll need to protect access to it using a mutex or queue or some such. See:
<https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Multithreading/ThreadSafetySummary/ThreadSafetySummary.html>
--
____________________________________________________________
Sean McBride, B. Eng email@hidden
Rogue Research www.rogue-research.com
Mac Software Developer Montréal, Québec, Canada
_______________________________________________
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