Re: [[NSFileManager alloc] init] considered thread-safe
Re: [[NSFileManager alloc] init] considered thread-safe
- Subject: Re: [[NSFileManager alloc] init] considered thread-safe
- From: Jens Alfke <email@hidden>
- Date: Tue, 4 May 2010 15:09:37 -0700
On May 4, 2010, at 2:03 PM, Quincey Morris wrote:
1. Why are the additional instances only "considered" thread-safe.
Doesn't anyone know?
I think it's using "considered" in a definite sense.
2. What does "thread-safe" mean in this context? I would take it to
mean that *any* single instance allocated with [[NSFileManager
alloc] init] can be used by *any* thread. Or does it mean that each
thread needs a unique instance, but such instances happily co-exist?
The latter, I think. What happened was that in 10.5 the NSFileManager
was extended to have a delegate, instead of being stateless. There are
obvious problems with multiple clients trying to set their own
delegates on the same object, or with a call on a background thread
invoking a delegate call to unrelated code that wasn't expecting to be
called on that thread.
3. If any single instance allocated with [[NSFileManager alloc]
init] is thread-safe in the fullest sense, why doesn't
[NSFileManager defaultManger] just return one of these, so that it
can be (considered) thread-safe too?
Because then you wouldn't be able to set a delegate on the shared
instance and have it be used on all calls involving that instance
(which is the most common case.)
—Jens_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden