Re: NSRecursiveLock problems
Re: NSRecursiveLock problems
- Subject: Re: NSRecursiveLock problems
- From: PCWiz <email@hidden>
- Date: Tue, 22 Dec 2009 19:07:42 -0700
I think I have actually found a one line solution for this problem.
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];
And that seemed to cure it. I'm not 100% sure if the problem is gone yet, but I've left it running for about an hour, and the issue would have usually appeared by now. I'll post back if it goes wrong again.
Independent Cocoa Developer, Macatomy Software
http://macatomy.com
On 2009-12-22, at 2:19 PM, Greg Guerin wrote:
> PCWiz wrote:
>
>> So for example I could do performSelectorOnMainThread with an NSMutableArray, for example, then have the method add the result object to the array and return it?
>
>
> As long as no other threads were doing anything with that array, I think that would work.
>
> Or define a very simple class with a couple of properties. The obvious advantage is that a class gives you precise control over mutability, thread-safety, types, etc.
>
> -- GG
>
> _______________________________________________
>
> 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
_______________________________________________
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