Merge pull request #391 from ReactiveX/dry-dispatch-queue-scheduler-qos
DRY DispatchQueueSchedulerQOS
This commit is contained in:
commit
e50053164b
|
|
@ -44,19 +44,7 @@ public class ConcurrentDispatchQueueScheduler: SchedulerType {
|
|||
*/
|
||||
@available(iOS 8, OSX 10.10, *)
|
||||
public convenience init(globalConcurrentQueueQOS: DispatchQueueSchedulerQOS) {
|
||||
let priority: qos_class_t
|
||||
switch globalConcurrentQueueQOS {
|
||||
case .UserInteractive:
|
||||
priority = QOS_CLASS_USER_INTERACTIVE
|
||||
case .UserInitiated:
|
||||
priority = QOS_CLASS_USER_INITIATED
|
||||
case .Default:
|
||||
priority = QOS_CLASS_DEFAULT
|
||||
case .Utility:
|
||||
priority = QOS_CLASS_UTILITY
|
||||
case .Background:
|
||||
priority = QOS_CLASS_BACKGROUND
|
||||
}
|
||||
let priority = globalConcurrentQueueQOS.QOSClass
|
||||
self.init(queue: dispatch_get_global_queue(priority, UInt(0)))
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,3 +38,17 @@ public enum DispatchQueueSchedulerQOS {
|
|||
*/
|
||||
case Background
|
||||
}
|
||||
|
||||
|
||||
@available(iOS 8, OSX 10.10, *)
|
||||
extension DispatchQueueSchedulerQOS {
|
||||
var QOSClass: qos_class_t {
|
||||
switch self {
|
||||
case .UserInteractive: return QOS_CLASS_USER_INTERACTIVE
|
||||
case .UserInitiated: return QOS_CLASS_USER_INITIATED
|
||||
case .Default: return QOS_CLASS_DEFAULT
|
||||
case .Utility: return QOS_CLASS_UTILITY
|
||||
case .Background: return QOS_CLASS_BACKGROUND
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81,19 +81,7 @@ public class SerialDispatchQueueScheduler: SchedulerType {
|
|||
*/
|
||||
@available(iOS 8, OSX 10.10, *)
|
||||
public convenience init(globalConcurrentQueueQOS: DispatchQueueSchedulerQOS, internalSerialQueueName: String = "rx.global_dispatch_queue.serial") {
|
||||
let priority: qos_class_t
|
||||
switch globalConcurrentQueueQOS {
|
||||
case .UserInteractive:
|
||||
priority = QOS_CLASS_USER_INTERACTIVE
|
||||
case .UserInitiated:
|
||||
priority = QOS_CLASS_USER_INITIATED
|
||||
case .Default:
|
||||
priority = QOS_CLASS_DEFAULT
|
||||
case .Utility:
|
||||
priority = QOS_CLASS_UTILITY
|
||||
case .Background:
|
||||
priority = QOS_CLASS_BACKGROUND
|
||||
}
|
||||
let priority = globalConcurrentQueueQOS.QOSClass
|
||||
self.init(queue: dispatch_get_global_queue(priority, UInt(0)), internalSerialQueueName: internalSerialQueueName)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue