• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Importance of thread safety and performance.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Importance of thread safety and performance.
      • From: Jonathon Mah <email@hidden>
  • Prev by Date: Re: Documentation frustrations
  • Next by Date: Re: Documentation frustrations
  • Previous by thread: Re: Entities without an NSManagedObjectContext?
  • Next by thread: Re: Importance of thread safety and performance.
  • Index(es):
    • Date
    • Thread