• 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: NSXMLParser thread safe?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSXMLParser thread safe?


  • Subject: Re: NSXMLParser thread safe?
  • From: Graham Cox <email@hidden>
  • Date: Sat, 02 Jun 2012 12:58:14 +1000

On 02/06/2012, at 11:15 AM, Kyle Sluder wrote:

> It's important to note that operation queues (and dispatch queues for that matter) do not guarantee anything about what threads your operations execute on. Apple's notoriously slippery definition of "thread-safe" can still bite you if the implication is that an NSXMLParser instance is safe to use from a non-main thread as long as *all* uses are from the *same* thread. That would make it unsafe to access the same NSXMLParser instance from two different NSOperations.


Right, thanks for the clarification.

In this case, it's not the same NSXMLParser instance - it's a new instance for each file I need to parse.

I found the source of my crashes - I was sharing an NSTextLayout object among the different objects used to layout text. Previously that worked on the main thread because only one was in use at a time, but it's not thread-safe. Making a new instance each time fixed that problem.

A similar issue concerned the use of [NSFileManager sharedManager] - making that a new instance instead allowed access from several threads (I believe this particular case is documented).

There are still some shared objects, such as the NSFontManager, but that hasn't caused any problems so far.


--Graham


_______________________________________________

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

References: 
 >Re: NSXMLParser thread safe? (From: Nick Zitzmann <email@hidden>)
 >Re: NSXMLParser thread safe? (From: Graham Cox <email@hidden>)
 >Re: NSXMLParser thread safe? (From: Kyle Sluder <email@hidden>)

  • Prev by Date: Re: NSXMLParser thread safe?
  • Next by Date: NSOperationQueue
  • Previous by thread: Re: NSXMLParser thread safe?
  • Next by thread: iOS preferences outside the application bundle
  • Index(es):
    • Date
    • Thread