Last active
August 12, 2016 07:33
-
-
Save yota345/b5e16611d32f1d178fdeb43706a17a60 to your computer and use it in GitHub Desktop.
RxScheduler.swift (https://github.com/takuwan0405/RxSwiftSample)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import RxSwift | |
import RxCocoa | |
/** | |
RxSwiftで同期・非同期・並列処理をするためのシングルトン | |
- main: 同期処理 | |
- serialBackground: 非同期処理 | |
- concurrentBackground: 並列処理 | |
*/ | |
struct RxScheduler { | |
static let sharedInstance = RxScheduler() | |
let main: SerialDispatchQueueScheduler | |
let serialBackground: SerialDispatchQueueScheduler | |
let concurrentBackground: ImmediateSchedulerType | |
init() { | |
main = MainScheduler.instance | |
serialBackground = SerialDispatchQueueScheduler(globalConcurrentQueueQOS: .Default) | |
let operationQueue = NSOperationQueue() | |
operationQueue.maxConcurrentOperationCount = 5 | |
operationQueue.qualityOfService = NSQualityOfService.UserInitiated | |
concurrentBackground = OperationQueueScheduler(operationQueue: operationQueue) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment