• 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
Re: [[NSFileManager alloc] init] considered thread-safe
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [[NSFileManager alloc] init] considered thread-safe


  • Subject: Re: [[NSFileManager alloc] init] considered thread-safe
  • From: Ken Ferry <email@hidden>
  • Date: Fri, 14 May 2010 13:46:55 -0700

On Fri, May 14, 2010 at 1:34 PM, Michael Ash <email@hidden> wrote:

> On Fri, May 14, 2010 at 1:12 PM, Ken Ferry <email@hidden> wrote:
> > On Wed, May 5, 2010 at 11:33 AM, Michael Ash <email@hidden>
> wrote:
> >>
> >> On Wed, May 5, 2010 at 2:29 PM, Jens Alfke <email@hidden> wrote:
> >> >
> >> > On May 5, 2010, at 8:50 AM, Michael Ash wrote:
> >> >
> >> >>> Delegates are the only reason the doc says anything other than "go
> >> >>> nuts".
> >> >>>  This is what both Jens and I were trying to say.
> >> >>
> >> >> Is this true for all OS X versions, for 10.6+, or some other
> >> >> combination?
> >> >
> >> > For all, I think, although the issue doesn’t apply prior to 10.5
> because
> >> > there wasn’t a delegate. Aside from the delegate, NSFileManager is
> really
> >> > just a stateless procedural API wrapped up in an object instance, so
> it has
> >> > the same thread safety as the underlying filesystem calls, i.e. “go
> nuts”.
> >>
> >> That's what I would have thought, but it was explicitly listed as not
> >> being thread safe before 10.5, and is still listed as "v10.5 and
> >> later" next to the entry that marks it as thread safe in the Cocoa
> >> thread safety summary.
> >>
> >> Just because the API is stateless doesn't mean the object itself
> >> doesn't have any state underneath. It *shouldn't*, but I'd tend to
> >> trust the API docs.
> >>
> >> However, I'm only targeting 10.5 these days, and that doc answers my
> >> question, so I'm in good shape! I should have looked there first.
> >
> > There did used to be thread-safety problems..  the class was redone when
> the
> > NSError returning methods were added in 10.5.
> > There was one lesser thread safety fix in 10.6.  +defaultManager was
> > previously using the simple version of a singleton method Mike discusses
> at
> > <
> http://www.mikeash.com/pyblog/friday-qa-2009-10-02-care-and-feeding-of-singletons.html
> >.
> >  This could potentially cause a crash if you managed to use the
> > defaultManager in the midst of its setup.
> > The workaround for 10.5 would be to call +defaultManager once from the
> main
> > thread before[1] it might happen on a background thread. This is pretty
> > likely to happen as a normal part of app initialization.
>
> Thanks for the detailed reply!
>
> Regarding that 10.5 singleton safety bug, is this documented anywhere?
> It seems like there are a lot of minor bugs which get fixed in later
> OS revisions but persist in earlier ones that we often have to support
> for a while. There are often easy workarounds like this, but we don't
> find out they're necessary until we happen, by chance, to say the
> right thing to the right Apple engineer on a mailing list.
>
> I know Apple documentation concentrates heavily on the latest release,
> and with good cause, but it would be great if little stuff like this
> could make it in somewhere. I don't know if you're the right person to
> say this to, but I figured I'd mention it just in case.


There's the release notes, but they're already long enough to put people
off, and we do actually want everyone to read those.  I don't think this one
made the notes, which was probably a fair decision - I'm not sure anyone has
ever hit it in practice.  It was noticed in code inspection.

Anyway, noted, though yes, I'm not a terribly helpful person to tell about
it. :-)

(I didn't do any of this work, by the way, just relaying it.)

-Ken
_______________________________________________

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

  • Follow-Ups:
    • Re: [[NSFileManager alloc] init] considered thread-safe
      • From: Michael Ash <email@hidden>
References: 
 >[[NSFileManager alloc] init] considered thread-safe (From: Quincey Morris <email@hidden>)
 >Re: [[NSFileManager alloc] init] considered thread-safe (From: Quincey Morris <email@hidden>)
 >Re: [[NSFileManager alloc] init] considered thread-safe (From: Ken Ferry <email@hidden>)
 >Re: [[NSFileManager alloc] init] considered thread-safe (From: Quincey Morris <email@hidden>)
 >Re: [[NSFileManager alloc] init] considered thread-safe (From: Ken Ferry <email@hidden>)
 >Re: [[NSFileManager alloc] init] considered thread-safe (From: Michael Ash <email@hidden>)
 >Re: [[NSFileManager alloc] init] considered thread-safe (From: Jens Alfke <email@hidden>)
 >Re: [[NSFileManager alloc] init] considered thread-safe (From: Michael Ash <email@hidden>)
 >Re: [[NSFileManager alloc] init] considered thread-safe (From: Ken Ferry <email@hidden>)
 >Re: [[NSFileManager alloc] init] considered thread-safe (From: Michael Ash <email@hidden>)

  • Prev by Date: Re: TUTORIAL: Generating Unique ID Strings
  • Next by Date: Re: TUTORIAL: Generating Unique ID Strings
  • Previous by thread: Re: [[NSFileManager alloc] init] considered thread-safe
  • Next by thread: Re: [[NSFileManager alloc] init] considered thread-safe
  • Index(es):
    • Date
    • Thread