Skip to content

Instantly share code, notes, and snippets.

@yota345
Last active August 12, 2016 07:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yota345/b5e16611d32f1d178fdeb43706a17a60 to your computer and use it in GitHub Desktop.
Save yota345/b5e16611d32f1d178fdeb43706a17a60 to your computer and use it in GitHub Desktop.
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