Re: Concurrent tasks are getting hung up
Re: Concurrent tasks are getting hung up
- Subject: Re: Concurrent tasks are getting hung up
- From: Steve Mills <email@hidden>
- Date: Sat, 11 Oct 2014 00:01:25 -0500
On Oct 10, 2014, at 10:00:02, Kyle Sluder <email@hidden> wrote:
> NSOperationQueue works by dispatching your blocks to the global async GCD queue. If you send a thousand blocks to be async processed at once, GCD will keep spinning up threads to try to service them until it exhausts the thread limit and your process deadlocks.
>
> It sucks, but you have to be judicious in the number of blocks you submit to the global queue. Set a max operation count on your NSOperationQueue.
OK, that makes sense. The docs for NSOperationQueue made it sound like it would take care of all that for you, figuring out how many threads to create based on current load, executing them as resources became available, etc. I've set it to 16 just for testing and that seems to prevent the blocking I was getting before. Except now the main thread blocks in the code that creates and adds the tasks to the queue. I've just re-read the docs and found the small section that talks about not flooding the queue with tons of operations, but handling batches in each operation or using a completion block to signal another operation to be created if there's still data left to process. It sure would've helped if this section would've been highlighted when I read it the first time.
> https://developer.apple.com/library/mac/qa/qa1238/_index.html
Ah, thanks.
--
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