views:

459

answers:

1

I have a singleton NSOperationQueue that handles all of my network requests. I'm noticing, however, that when I have one particularly long operation running (this particular operation takes at least 25 seconds), my other operations don't run until it completes.

maxConcurrentOperationCount is set to NSOperationQueueDefaultMaxConcurrentOperationCount, so I don't believe that's the issue.

Any reason why this would be happening? Besides spawning multiple NSOperationQueues (a solution that I'm not sure would work, nor am I sure it's a good idea), what's the best way to fix this problem?

Thanks.

+3  A: 

According to the NSOperationQueue class referenceNSOperationQueueDefaultMaxConcurrentOperationCount means that "the default maximum number of operations is determined dynamically by the NSOperationQueue object based on current system conditions." I don't see anything that says the default will be > 1 (especially on a single-CPU system).

Try calling -setMaxConcurrentOperationCount: to explicitly set a larger value, and see if that helps.

David Gelhar
I set it to an explicitly larger value (4), and that does fix the problem.It's confusing, because setting it to NSOperationQueueDefaultMaxConcurrentOperationCount (which has a value of -1) is, according to the documentation, supposed to turn up the concurrency as high as it can reasonably go. Even on an iPhone, there's no reason why that value shouldn't, in practice, allow multiple threads.
Greg Maletic