Search code examples
iosafnetworkingafnetworking-2

Does AFNetworking dequeue a new request before completion block finishes, when using maxConcurrentOperationCount=1?


I'm using AFNetworking with setting it's built-in operationQueue's maxConcurrentOperationCount value to 1 (Basically I want to dispatch requests serially).

I wonder if a new request will be dequeued from the operation queue before ongoing request's completion block finishes. Will a new request start before calling the completion queue, or will it wait for completion block to finish.

Thanks


Solution

  • As explained by @mattt in his comment, operation queue used by AFNetworking will start the new request during completionBlock of the previous one is executing. His comment answers my original question.

    However, because AFNetworking calls corresponding success/failure blocks of AFHTTPRequestOperation objects inside a concurrent dispatch_queue, currently you can not guarantee completion block call order to be same with request enqueue order even if you use maxConcurrentOperationCount = 1. Details about the issue can be found in here

    Thanks to @mattt for the help!