Tuesday, April 21, 2020

Connection limit cocurrent count in iOS

https://stackoverflow.com/questions/22617233/timeout-when-issuing-too-many-afnetworking-requests

https://www.raywenderlich.com/5293-operation-and-operationqueue-tutorial-in-swift#toc-anchor-003

Creating an OperationQueue is very straightforward, as you can see. Naming your queues helps with debugging, since the names show up in Instruments or the debugger. The maxConcurrentOperationCount is set to 1 for the sake of this tutorial to allow you to see operations finishing one by one. You could leave this part out and allow the queue to decide how many operations it can handle at once — this would further improve performance.
How does the queue decide how many operations it can run at once? That’s a good question! It depends on the hardware. By default, OperationQueue does some calculation behind the scenes, decides what’s best for the particular platform it’s running on, and launches the maximum possible number of threads.
Consider the following example: Assume the system is idle and there are lots of resources available. In this case, the queue may launch eight simultaneous threads. Next time you run the program, the system may be busy with other, unrelated operations which are consuming resources. This time, the queue may launch only two simultaneous threads. Because you’ve set a maximum concurrent operations count in this app, only one operation will happen at a time.

http://blog.lightstreamer.com/2013/01/on-ios-url-connection-parallelism-and.html


No comments:

Post a Comment