• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Concurrent tasks are getting hung up
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Concurrent tasks are getting hung up


  • Subject: Re: Concurrent tasks are getting hung up
  • From: Jim Crate <email@hidden>
  • Date: Fri, 10 Oct 2014 11:27:42 -0400

On Oct 10, 2014, at 11:00 AM, Kyle Sluder <email@hidden> wrote:

>> On Oct 10, 2014, at 6:42 AM, Steve Mills <email@hidden> wrote:
>>
>> I've only created one NSOperationQueue and added many NSInvocationOperation to it.
>
> 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.

I ran into the same problem in my first foray into using NSOperationQueue.  When adding several hundred block operations to the queue, it pretty much choked trying to run all several hundred at once.  Now, when I create an NSOperationQueue for what could be more than a few operations, I always use:

myQueue.maxConcurrentOperationCount = [[NSProcessInfo processInfo] processorCount];

The processorCount is actually logical core count, so on my 4-core i7 it returns 8.

Jim


_______________________________________________

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


  • Follow-Ups:
    • Re: Concurrent tasks are getting hung up
      • From: Kevin Meaney <email@hidden>
References: 
 >Concurrent tasks are getting hung up (From: Steve Mills <email@hidden>)
 >Re: Concurrent tasks are getting hung up (From: Jens Alfke <email@hidden>)
 >Re: Concurrent tasks are getting hung up (From: Steve Mills <email@hidden>)
 >Re: Concurrent tasks are getting hung up (From: Greg Parker <email@hidden>)
 >Re: Concurrent tasks are getting hung up (From: Steve Mills <email@hidden>)
 >Re: Concurrent tasks are getting hung up (From: Greg Parker <email@hidden>)
 >Re: Concurrent tasks are getting hung up (From: Steve Mills <email@hidden>)
 >Re: Concurrent tasks are getting hung up (From: Kyle Sluder <email@hidden>)

  • Prev by Date: Re: Concurrent tasks are getting hung up
  • Next by Date: Re: Concurrent tasks are getting hung up
  • Previous by thread: Re: Concurrent tasks are getting hung up
  • Next by thread: Re: Concurrent tasks are getting hung up
  • Index(es):
    • Date
    • Thread