Skip to content

Commit

Permalink
Fix linux
Browse files Browse the repository at this point in the history
  • Loading branch information
freak4pc committed Oct 6, 2020
1 parent 28a9b8c commit f998d98
Showing 1 changed file with 15 additions and 29 deletions.
44 changes: 15 additions & 29 deletions RxBlocking/RunLoopLock.swift
Expand Up @@ -12,12 +12,7 @@ import RxSwift

#if os(Linux)
import Foundation
#if compiler(>=5.0)
let runLoopMode: RunLoop.Mode = .default
#else
let runLoopMode: RunLoopMode = .defaultRunLoopMode
#endif

let runLoopModeRaw: CFString = unsafeBitCast(runLoopMode.rawValue._bridgeToObjectiveC(), to: CFString.self)
#else
let runLoopMode: CFRunLoopMode = CFRunLoopMode.defaultMode
Expand Down Expand Up @@ -67,32 +62,23 @@ final class RunLoopLock {
}
if let timeout = self.timeout {
#if os(Linux)
switch Int(CFRunLoopRunInMode(runLoopModeRaw, timeout, false)) {
case kCFRunLoopRunFinished:
return
case kCFRunLoopRunHandledSource:
return
case kCFRunLoopRunStopped:
return
case kCFRunLoopRunTimedOut:
throw RxError.timeout
default:
fatalError("This failed because `CFRunLoopRunResult` wasn't bridged to Swift.")
}
let runLoopResult = CFRunLoopRunInMode(runLoopModeRaw, timeout, false)
#else
switch CFRunLoopRunInMode(runLoopMode, timeout, false) {
case .finished:
return
case .handledSource:
return
case .stopped:
return
case .timedOut:
throw RxError.timeout
default:
return
}
let runLoopResult = CFRunLoopRunInMode(runLoopMode, timeout, false)
#endif

switch runLoopResult {
case .finished:
return
case .handledSource:
return
case .stopped:
return
case .timedOut:
throw RxError.timeout
default:
return
}
}
else {
CFRunLoopRun()
Expand Down

0 comments on commit f998d98

Please sign in to comment.