Concurrent tasks are getting hung up
Concurrent tasks are getting hung up
- Subject: Concurrent tasks are getting hung up
- From: Steve Mills <email@hidden>
- Date: Thu, 09 Oct 2014 08:37:32 -0500
I've made my first foray into multitasking with Cocoa and am experiencing a little snag that I was hoping someone could help me with. I read the Concurrency Programming Guide (it was in one sitting, so my eyes probably glazed over a few times) and decided to try NSOperationQueue. First I queued each task with NSInvocationOperation's initWithTarget:selector:object:. I later tried the queue's addOperationWithBlock: instead. The task method loads a CGImage via url, creates a small CGBitmapContext, draws the image into it, compares its bits to another bitmap, adds the url to an NSMutableArray property owned by the object if the bitmaps match, and releases the image and bitmap.
It worked great when the list of urls is small, but when I ran it on a large set, some of the tasks get hung up on one of the CG calls, and I end up with a couple dozen threads that never finish. As mentioned above, I also tried addOperationWithBlock: to see if that would handle things any better. Same result. If I stick a few NSLog calls in the task that spit out messages to the Xcode console, that seems to help and the tasks no longer get hung up. But I can't ship that way. :) It also seemed to work fine if I set setMaxConcurrentOperationCount to 4 instead of leaving it alone (I have a new 6-code Mac Pro).
So, any ideas? I tried messing with different attributes on the object properties (atomic and nonatomic) for the class that owns the task method. The task method calls a method on another object, and that object stores data in instance variables and not properties. Any problem there? They're never access by anything other than the class itself.
--
Steve Mills
Drummer, Mac geek
_______________________________________________
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