Skip to content

Instantly share code, notes, and snippets.

@acchou
Created May 25, 2016 22:28
Show Gist options
  • Save acchou/7ecdee5375fdc8c2d500e479481180c0 to your computer and use it in GitHub Desktop.
Save acchou/7ecdee5375fdc8c2d500e479481180c0 to your computer and use it in GitHub Desktop.
//: Playground - noun: a place where people can play
import UIKit
import RxSwift
import RxCocoa
let ps = PublishSubject<Int>()
func pt() -> String {
let thread = NSThread.currentThread()
let main = thread.isMainThread ? "[Main] " : ""
let qos = currentThreadQos()
let tid = pthread_mach_thread_np(pthread_self())
return "[\(tid)] \(main)\(qos)"
}
ps
.subscribeOn(ConcurrentDispatchQueueScheduler(globalConcurrentQueueQOS: .UserInitiated))
.map {
print("map \(pt()) \($0)")
return $0
}
//.observeOn(ConcurrentDispatchQueueScheduler(globalConcurrentQueueQOS: .Utility))
.subscribeNext { (i: Int) in
print("subscribe \(pt()) \(i)")
}
ps.onNext(0)
ps.onNext(1)
ps.onNext(2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment