0001 // 0002 // Dispatch.swift 0003 // DispatchKit <https://github.com/anpol/DispatchKit> 0004 // 0005 // Copyright (c) 2014 Andrei Polushin. All rights reserved. 0006 // 0007 0008 import Foundation 0009 0010 public struct Dispatch { 0011 0012 public static var currentQueue: DispatchCurrentQueue { 0013 return DispatchCurrentQueue() 0014 } 0015 0016 public static var mainQueue: DispatchQueue { 0017 return DispatchQueue(rawValue: dispatch_get_main_queue()) 0018 } 0019 0020 public static var globalQueue: DispatchQueue { 0021 return getGlobalQueue(priority: .Default) 0022 } 0023 0024 public static func getGlobalQueue(priority priority: DispatchQueuePriority, flags: Int = 0) -> DispatchQueue { 0025 return DispatchQueue(rawValue: dispatch_get_global_queue(priority.rawValue, UInt(flags))) 0026 } 0027 0028 public static func getGlobalQueue(qosClass qosClass: DispatchQOSClass, flags: Int = 0) -> DispatchQueue { 0029 let identifier: Int 0030 if #available(iOS 8.0, *) { 0031 identifier = qosClass.rawValue 0032 } else { 0033 identifier = DispatchQueuePriority(qosClass: qosClass).rawValue 0034 } 0035 0036 return DispatchQueue(rawValue: dispatch_get_global_queue(identifier, UInt(flags))) 0037 } 0038 0039 } 0040
Dispatch.swift:21 return getGlobalQueue(priority: .Default)