Skip to content
Permalink
Browse files

Addressing PR comments

  • Loading branch information...
ryu1006 authored and kzaher committed Feb 20, 2019
1 parent bbb6a94 commit b8b9c67e1d95f354ee67f8c0c6cecf22bd5ae231
Showing with 8 additions and 3 deletions.
  1. +7 −2 Platform/DispatchQueue+Extensions.swift
  2. +1 −1 RxSwift/Schedulers/MainScheduler.swift
@@ -7,10 +7,15 @@
//
import Dispatch
import Foundation

extension DispatchQueue {
private static var token: DispatchSpecificKey<()> = {
let key = DispatchSpecificKey<()>()
DispatchQueue.main.setSpecific(key: key, value: ())
return key
}()

static var isMain: Bool {
return Thread.isMainThread
return DispatchQueue.getSpecific(key: token) != nil
}
}
@@ -47,7 +47,7 @@ public final class MainScheduler : SerialDispatchQueueScheduler {

/// In case this method is running on a background thread it will throw an exception.
public class func ensureRunningOnMainThread(errorMessage: String? = nil) {
if !Thread.isMainThread {
guard Thread.isMainThread else {
rxFatalError(errorMessage ?? "Running on background thread.")
}
}

0 comments on commit b8b9c67

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.