[BUG] Calls off multiple threads cannot run concurrently in Swift 4
Created by: DavePilks
Bug Report Checklist
-
Have you provided a full/minimal spec to reproduce the issue? -
What's the version of OpenAPI Generator used? -
Have you search for related issues/PRs?
Description
When creating the ResponseData
object in AlamofireImplementations.swift
, no dispatch queue is passed into the init
. This means that Alamofire
defaults to DispatchQueue.main
.
If you then have multiple threads trying to make service calls, they are all placed on the main queue and cannot run concurrently as there is only a single thread.
We noticed this as we were trying to break out of the callback pattern using a semaphore. This is when we noticed the blocking.
openapi-generator version
3.3.4
Steps to reproduce
Call Setup
- Use semaphore to block until call back is fire
- Return result from callback
Queuing
- Have multiple call running in the background queue
Expected Result The calls return once the call has been completed
Actual Result The calls block
Suggest a fix
The init
for the Alamofire
response takes in a queue parameter that is defaulted to nil
. Suggested fix is to provide DispatchQueue.global(qos: .background)
as the parameter to allow concurrency