[MacRuby-devel] thread-safety and collections in macruby
Terry Moore
tvmoore at mac.com
Tue Oct 18 22:41:55 PDT 2011
If you're not wring/changing the array no problems. But to be safe use Object#freeze...
Terry Moore
On 19/10/2011, at 6:26 PM, Michael Johnston <lastobelus at mac.com> wrote:
> Note, in my example I can also guarantee that none of the elements in b are going to be changed (for example, an array of strings)
> Cheerio,
>
> Michael Johnston
> lastobelus at mac.com
>
>
>
>
> On 2011-10-18, at 10:17 PM, Michael Johnston wrote:
>
>> In ObjC, the immutable collections are threadsafe.
>>
>> In macruby, are collections threadsafe to read only?
>>
>> ie, if I do this:
>>
>> a = [ ...] # an array that may or may not be changed
>>
>> b = a.dup # nowhere in the code is b ever used to add/delete/change an element
>>
>> is b thread-safe to read from multiple threads (queued operations/blocks)?
>>
>> also, is there any difference between doing
>>
>> b = a.dup
>>
>> and
>>
>> b = NSArray.arrayWithArray(a)
>>
>> Both result in class Array, so I assume there is no difference.
>>
>>
>>
>> Cheerio,
>>
>> Michael Johnston
>> lastobelus at mac.com
>>
>>
>>
>>
>> _______________________________________________
>> MacRuby-devel mailing list
>> MacRuby-devel at lists.macosforge.org
>> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
>
> _______________________________________________
> MacRuby-devel mailing list
> MacRuby-devel at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
More information about the MacRuby-devel
mailing list