我知道您可以通过执行以下操作来创建并发队列:
let queue = DispatchQueue(label: "My Awesome Queue", attributes: .concurrent)
但我没有看到用于创建序列队列的替代枚举,类似于:
let queue = DispatchQueue(label: "My Awesome Queue", attributes: .serial)
The only other possible option seems to be .initiallyInactive
, am I missing something?个
如何在SWIFT中指定我需要一个串行队列?
Note that I am using the above queues like this:个
queue.async {
// do task 1
}
queue.async {
// do task 2
}
// expect task 1 to start
// expect task 1 to finish
// expect task 2 to start
// expect task 2 to finish