Importance of thread safety and performance.
Importance of thread safety and performance.
- Subject: Importance of thread safety and performance.
- From: アンドレ(Andre) <email@hidden>
- Date: Fri, 8 Jul 2005 22:27:13 -0700
Hi all.
I'm going to be implementing a few custom classes and want to have it
thread-safe from the start.
I have a few ideas on how to go about this, but possible performance
problems have stalled my decision.
Ok, my first idea is to just make every accessor setter and methods
that alter data use NSLock to lock and unlock
any changed variables etc... My concern here is say [myObject
addObject:object] was called a large number of times,
all of the locking and unlocking would slow things down wouldn't it?
Another idea is to make two methods like -threadSafeAddObject and -
addObject...
The last idea is to have my object implement a simple setter like -
setReentrant:YES/NO and then each methods checks,
if (reentrant == YES) {[NSLock lock] .....} that way when I need
thread-safety I can sacrifice speed..
What do the experienced programmers think?
I would think that implementing a whole class(es) and then going back
and making it properly thread-safe would be
a pain.... would it be a waste of time or is it something that I
shouldn't care too much??
I would rather do things "the right way" first than waste my time
later in upkeep...
P.S Yes, at some point I plan on using Multithreading.
Thanks all.
Andre
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden