Default value of maxConcurrentOperationCount for NSOperationQueue

lakesh picture lakesh · Feb 21, 2013 · Viewed 9.7k times · Source

As the title suggests, what is the default value of the maxConcurrentOperationCount for NSOperationQueue?

Is it set to a value of 1?

Answer

iDev picture iDev · Feb 21, 2013

From the documentation,

The maximum number of concurrent operations set explicitly on the receiver using the setMaxConcurrentOperationCount: method. If no value has been explicitly set, this method returns NSOperationQueueDefaultMaxConcurrentOperationCount by default.

So it is NSOperationQueueDefaultMaxConcurrentOperationCount. If this is set, it will choose an appropriate value based on the number of available processors and other relevant factors.

This is how it is defined:

enum {
  NSOperationQueueDefaultMaxConcurrentOperationCount = -1
};

NSOperationQueueDefaultMaxConcurrentOperationCount: The default maximum number of operations is determined dynamically by the NSOperationQueue object based on current system conditions.