When testing my code under Sierra, I found that methods that previously handled parallel queues no longer worked.
When analyzing the error in my C ++ codebase, one of the users proposed a workaround that clearly indicated the destination for the queue declaration (see this post: a C ++ 11 application that uses dispatch_apply, not working under Mac OS Sierra ), which seems to have solved the problem.
In Swift 3, the following code will be used to execute closure at the same time, but it demonstrates a similar but C ++ example in the above message:
import Foundation import GameKit DispatchQueue.concurrentPerform(iterations: 1000) { index in let pauseTime = GKRandomSource.sharedRandom().nextInt(upperBound: 5) sleep(UInt32(pauseTime)) print(index) }
... however, when I execute it, it runs each block sequentially and the indices are displayed in numerical order.
Does anyone know how I could use the workaround recommended in this post to solve my "parallel" sending problems in Swift?
source share