Thread Safety - A Theoretical Question

2009-10-12 Thread André Berg
Hi, I am designing my first real class and I am wondering about thread safety. I have read the Cocoa Fundamentals and also the Threading Programming Guide but there was one question forming in my head which I couldn't quite find an answer for. I guess it is something that class designers

Re: Thread Safety - A Theoretical Question

2009-10-12 Thread Nick Zitzmann
On Oct 12, 2009, at 2:47 PM, André Berg wrote: In that case is it my responsibility to guard all access to my class' thread unsafe ivars (like mutable objects for example) or is it the responsibility of the user of my class to guard all access to my class' instances in his code? It

Re: Thread Safety - A Theoretical Question

2009-10-12 Thread Peter Duniho
On Oct 12, 2009, at 1:47 PM, André Berg wrote: [...] My class internally doesn't use any threads at all (well apart from an NSTask ivar and readInBackgroundAndNotify). The only scenario I can think of that would be dangerous is if in the calling code (the code from the user of my class)

Re: Thread Safety - A Theoretical Question

2009-10-12 Thread Greg Parker
On Oct 12, 2009, at 1:47 PM, André Berg wrote: I am designing my first real class and I am wondering about thread safety. I have read the Cocoa Fundamentals and also the Threading Programming Guide but there was one question forming in my head which I couldn't quite find an answer for. I

Re: Thread Safety - A Theoretical Question

2009-10-12 Thread Dave Keck
In that case is it my responsibility to guard all access to my class' thread unsafe ivars (like mutable objects for example) or is it the responsibility of the user of my class to guard all access to my class' instances in his code? When dealing with Cocoa, the rule is that all classes must

Re: Thread Safety - A Theoretical Question

2009-10-12 Thread Greg Guerin
André Berg wrote: I am designing my first real class and I am wondering about thread safety. Thoughts on reading the above: What do you mean by real class? Are the other classes you've designed merely sham classes? Toy classes? Mock classes? What other classes have you designed?

Re: Thread Safety - A Theoretical Question

2009-10-12 Thread Jens Alfke
On Oct 12, 2009, at 2:47 PM, Dave Keck wrote: I recommend adopting this rule too, and only making classes thread safe if it makes sense. +1 While making every class you ever write thread-safe might be a good intellectual exercise, it's hard and time consuming, and I doubt there's many of

Re: Thread Safety - A Theoretical Question

2009-10-12 Thread André Berg
Huge thanks to everyone. Your time is valuable and I appreciate it that you are spending it on helping me. A lot of high quality, very useful answers. I have decided to try and work towards the following pattern (in Mr. Parker's nice words): One thread per instance. Much of Core Data works