Re: NSRecursiveLock problems
Re: NSRecursiveLock problems
- Subject: Re: NSRecursiveLock problems
- From: Douglas Davidson <email@hidden>
- Date: Wed, 23 Dec 2009 08:45:45 -0800
On Dec 22, 2009, at 6:07 PM, PCWiz wrote:
The issue class in my case is NSLayoutManager. I dug through the
docs for NSLayoutManager and read the section on thread safety.
There were 2 steps to achieving thread safety with NSLayoutManager.
First, if the NSLayoutManager belonged to an NSTextView, then the
text view must not be displayed while a secondary thread is making
changes using its layout manager. The second part was to turn off
background layout for the NSLayoutManager.
In my case the layout manager was not tied to a text view (I was
just using it to get the size of an attributed string) so all I had
to do was this:
[layoutManager setBackgroundLayoutEnabled:NO];
Those are the two criteria I specified in the release notes as being
essential for using NSLayoutManager on a background thread. In
general, an NSLayoutManager and associated objects can be used from
only a single thread at once, but as long as you have eliminated
simultaneous accesses to them from other threads, they should be OK.
The tricky part is that view display and background layout will happen
automatically on the main thread, so you need to make sure those will
not occur for your layout manager while you are using it on a
background thread. If you have done that and still see threading
issues, please file a bug.
Douglas Davidson
_______________________________________________
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