Re: looking for a memory problem
Re: looking for a memory problem
- Subject: Re: looking for a memory problem
- From: Mike Abdullah <email@hidden>
- Date: Wed, 18 Jul 2012 00:09:37 +0100
On 17 Jul 2012, at 18:10, Martin Hewitson wrote:
> So my potential solution for this is:
>
> NSSpellChecker *checker = [NSSpellChecker sharedSpellChecker];
> __block NSRange range = NSMakeRange(0, 0);
> while (range.location < [aString length]) {
>
> dispatch_sync(dispatch_get_main_queue(), ^{
> range = [checker checkSpellingOfString:aString startingAt:range.location];
> });
>
> // update range
> }
>
> Where this piece of code will run on multiple threads.
>
> Does this look like a reasonable approach to ensuring thread safety?
Two potential problems:
- If the main thread is waiting on your thread/queue to do its work, then you’ve got a deadlock. Hopefully your code never does that
- If you run this code on the main thread, it’ll deadlock also. You might find something like KSThreadProxy a neater solution to this problem.
_______________________________________________
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