dispatch_barrier_async equivalent in Swift 3

前端 未结 1 730
别那么骄傲
别那么骄傲 2021-02-01 05:22

Refactoring a colleague\'s code, and I\'m looking for the equivalent of dispatch_barrier_async in swift 3. There are a lot of queues at play, and his design is to b

1条回答
  •  抹茶落季
    2021-02-01 05:39

    The async() method has a flags parameter which accepts a .barrier option:

    func subscribe(subscriber: DaoDelegate) {
      (self.subscribers.q).async(flags: .barrier) { 
        //...
      }
    }
    

    0 讨论(0)
提交回复
热议问题