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?  And implemented?

In what circumstances is this real class going to be used? Are you designing it for your own use or for others?


My class internally doesn't use any threads at all (well apart from an NSTask ivar and readInBackgroundAndNotify).


Thoughts on reading the above:

You're using readInBackgroundAndNotify, which implies a run-loop for correct operation, IIRC. Is that fact documented for your class? Will the class work properly in a run-loop in a non-main thread?

What is the NSTask doing? Is the use of NSTask apparent to users of the class? Is it necessary for users to know this (other than the dependence on run-loop necessitated by readInBackgroundAndNotify)?


And I agree with the other comments: thread safety depends on what the class does, and how it's intended to be used. There isn't one universal answer.

  -- GG


_______________________________________________

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