Re: [MacRuby-devel] thread-safety and collections in macruby

2011-10-22 Thread Terry Moore
That's odd. I would still use freeze more rubyish... :) Terry Moore On 22/10/2011, at 6:41 PM, Michael Johnston wrote: > Thanks, I am using: > > results = NSArray.arrayWithArray(worker_results) > > which although it reports true for is_a?(NSMutableArray) is immutable. > > Cheerio, > > Micha

Re: [MacRuby-devel] thread-safety and collections in macruby

2011-10-21 Thread Michael Johnston
Thanks, I am using: results = NSArray.arrayWithArray(worker_results) which although it reports true for is_a?(NSMutableArray) is immutable. Cheerio, Michael Johnston lastobe...@mac.com On 2011-10-20, at 3:47 PM, terl wrote: > Just a note to the original question > > macruby collection

Re: [MacRuby-devel] thread-safety and collections in macruby

2011-10-21 Thread Michael Johnston
Thanks. Since there are a lot of options I'm going to do a benchmark to compare them. For my particular workload, the problem is a "changing gears" sort of problem, where I need to collect an aggregate result to the ui. Since the worker loop is pretty consistent in the time each iteration takes

Re: [MacRuby-devel] thread-safety and collections in macruby

2011-10-20 Thread terl
Just a note to the original question macruby collections are based on objc mutable collections...e.g. a = %w{my array of strings} ["my","array","of"strings"] b = a.dup. b is still a mutable array. c = NSarray.alloc.initWithArray( a ) immutable array c << "hi" runtime error cannot modify

Re: [MacRuby-devel] thread-safety and collections in macruby

2011-10-20 Thread Andy Park
On 19 Oct 2011, at 22:43, Jordan K. Hubbard wrote: > If the mail archives were easier to search, I'd pull it up, but it isn't and > I'm too lazy. :) > I set up an entry in gmane for the mailing list a while ago in order to search the list a bit better: http://news.gmane.org/gmane.comp.lang

Re: [MacRuby-devel] thread-safety and collections in macruby

2011-10-20 Thread Matt Aimonetti
Hmm thanks, I didn't realize we had a google groups mirror. I'm wondering if we shouldn't just move there since it's much easier to use and maintain than macosforge. Thoughts, ideas, suggestions? - Matt On Thu, Oct 20, 2011 at 12:13 AM, Sven A. Schmidt wrote: > I found that searching the google

Re: [MacRuby-devel] thread-safety and collections in macruby

2011-10-20 Thread Sven A. Schmidt
I found that searching the google groups mirror was much easier and this might be the thread you're referring to: https://groups.google.com/d/topic/macruby/ceyNNqComMc/discussion -sas On Oct 19, 2011, at 22:43, Jordan K. Hubbard wrote: > > On Oct 19, 2011, at 11:38 AM, Terry Moore wrote: > >

Re: [MacRuby-devel] thread-safety and collections in macruby

2011-10-19 Thread Matt Aimonetti
I believe someone (Ernie or someone else) did indeed extract some of the dispatch gem's mixins. - Matt On Wed, Oct 19, 2011 at 1:43 PM, Jordan K. Hubbard wrote: > > On Oct 19, 2011, at 11:38 AM, Terry Moore wrote: > > Yes. But he does state it is a read only not modified array. My > understandi

Re: [MacRuby-devel] thread-safety and collections in macruby

2011-10-19 Thread Jordan K. Hubbard
On Oct 19, 2011, at 11:38 AM, Terry Moore wrote: > Yes. But he does state it is a read only not modified array. My understanding > is. 'Array' is an NSMutableArray, I was merely suggesting using freeze to > throw that exception just in case there maybe some code attempting to > write/modify. >

Re: [MacRuby-devel] thread-safety and collections in macruby

2011-10-19 Thread Terry Moore
Yes. But he does state it is a read only not modified array. My understanding is. 'Array' is an NSMutableArray, I was merely suggesting using freeze to throw that exception just in case there maybe some code attempting to write/modify. Mutex is the way to go but it also has an overhead. Terry M

Re: [MacRuby-devel] thread-safety and collections in macruby

2011-10-19 Thread Matt Aimonetti
The proper way to protect mutable objects is to use a mutex: http://www.ruby-doc.org/core-1.9.2/Mutex.html - Matt Sent from my iPhone On Oct 19, 2011, at 8:06, Chuck Remes wrote: > > On Oct 19, 2011, at 12:41 AM, Terry Moore wrote: > >> If you're not wring/changing the array no problems. Bu

Re: [MacRuby-devel] thread-safety and collections in macruby

2011-10-19 Thread Chuck Remes
On Oct 19, 2011, at 12:41 AM, Terry Moore wrote: > 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 wrote: > >> Note, in my example I can also guarantee that none of the elements in b are

Re: [MacRuby-devel] thread-safety and collections in macruby

2011-10-18 Thread Terry Moore
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 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) > Cheer

Re: [MacRuby-devel] thread-safety and collections in macruby

2011-10-18 Thread Michael Johnston
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 lastobe...@mac.com On 2011-10-18, at 10:17 PM, Michael Johnston wrote: > In ObjC, the immutable collections are threadsafe. > > In mac

[MacRuby-devel] thread-safety and collections in macruby

2011-10-18 Thread Michael Johnston
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 t