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 deal differently with.

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) there are two threads which could simultaneously access the same instance of my class.

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?

With regards to this, should I care about thread safety at all? If you are designing a class, even without any concurrency in it at all, where do you decide to worry about thread safety in code outside your reach?

I know this is a somewhat loaded question, but I do appreciate any pointers and one-liners.
Thanks a lot for reading!

Cheers,

André
_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to