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 (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com