Alamofire源码解析 - DispatchQueue+Alamofire

extension DispatchQueue {
    static var userInteractive: DispatchQueue { return DispatchQueue.global(qos: .userInteractive) }
    static var userInitiated: DispatchQueue { return DispatchQueue.global(qos: .userInitiated) }
    static var utility: DispatchQueue { return DispatchQueue.global(qos: .utility) }
    static var background: DispatchQueue { return DispatchQueue.global(qos: .background) }

    func after(_ delay: TimeInterval, execute closure: @escaping () -> Void) {
        asyncAfter(deadline: .now() + delay, execute: closure)
    }

    func syncResult(_ closure: () -> T) -> T {
        var result: T!
        sync { result = closure() }
        return result
    }
}
  • 获取不同优先级的队列
  • 延迟执行的方法
  • 同步调用

你可能感兴趣的:(Alamofire源码解析 - DispatchQueue+Alamofire)