Re: NSUserDefaults & thread safety
Re: NSUserDefaults & thread safety
- Subject: Re: NSUserDefaults & thread safety
- From: Derrick Bass <email@hidden>
- Date: Wed, 25 Jan 2006 19:45:56 -0600
On Jan 25, 2006, at 10:58 AM, Chris Hanson wrote:
On Jan 25, 2006, at 4:22 AM, Derrick Bass wrote:
In general "not thread safe" means that it is okay to use from
different threads, as long as you make to sure to use some sort of
synchronization so only one thread at a time is accessing the
resource.
This is not the case in Cocoa. In Cocoa, "not thread-safe" means
that some functionality is only safe to use from the main thread
unless otherwise documented.
The reason for this is that the functionality in question may be
invoked by the Cocoa frameworks themselves. This means that you
cannot make sure that all access to the functionality are
appropriately synchronized, since you cannot modify Cocoa to do so.
Well, if that's true, then we have two major problems.
1. Apple's documentation clearly says otherwise. It says exactly what
I said above. From <http://developer.apple.com/documentation/Cocoa/
Conceptual/Multithreading/articles/CocoaSafety.html> we have:
"The classes and functions in the following table are generally
considered to be thread-safe. You can use them from multiple threads
without first acquiring a lock."
and
"The classes and functions in the following table are generally not
thread-safe. Some of these items may be made thread-safe in the
future but for now you should use a lock or the @synchronized
directive if there is a potential for access by multiple threads. For
some objects, like NSAppleScript, you should use the object only from
your application’s main thread. Check the class documentation to see
if any additional guidelines are available."
and
2. If what you say is true then Cocoa uses a different definition of
thread-safe from the rest of the world and should pick another word.
Derrick
_______________________________________________
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