IPhone: NSOperationQueue launches operations in serial

I have a singleton NSOperationQueue that handles all my network requests. However, I notice that when I have one very long operation running (this particular operation takes at least 25 seconds), my other operations are not performed until it completes.

maxConcurrentOperationCount is set to NSOperationQueueDefaultMaxConcurrentOperationCount, so I don't think that is the problem.

Any reason why this is happening? Besides spawning a few NSOperationQueues (a solution that I'm not sure will work, and I'm not sure if this is a good idea), what is the best way to fix this problem?

Thanks.

+4
source share
1 answer

According to the NSOperationQueue class reference, NSOperationQueueDefaultMaxConcurrentOperationCount means that "the default maximum number of operations is determined dynamically by an NSOperationQueue object based on current system conditions." I don’t see anything that says that by default it will be> 1 (especially on a system with one processor).

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

+4
source

Source: https://habr.com/ru/post/1308189/


All Articles