Fixes problem compiling 'CurrentThreadScheduler'.

This commit is contained in:
Krunoslav Zaher 2015-12-25 19:58:58 -08:00
parent aa89d2f7d4
commit 09e9abf2b7
2 changed files with 14 additions and 7 deletions

View File

@ -11,9 +11,15 @@ import Foundation
#if os(Linux)
let CurrentThreadSchedulerKeyInstance = "RxSwift.CurrentThreadScheduler.SchedulerKey"
let CurrentThreadSchedulerQueueKeyInstance = "RxSwift.CurrentThreadScheduler.Queue"
typealias CurrentThreadSchedulerValue = NSString
let CurrentThreadSchedulerValueInstance = "RxSwift.CurrentThreadScheduler.SchedulerKey" as NSString
#else
let CurrentThreadSchedulerKeyInstance = CurrentThreadSchedulerKey()
let CurrentThreadSchedulerQueueKeyInstance = CurrentThreadSchedulerQueueKey()
let CurrentThreadSchedulerKeyInstance = CurrentThreadSchedulerKey()
let CurrentThreadSchedulerQueueKeyInstance = CurrentThreadSchedulerQueueKey()
typealias CurrentThreadSchedulerValue = CurrentThreadSchedulerKey
let CurrentThreadSchedulerValueInstance = CurrentThreadSchedulerKeyInstance
class CurrentThreadSchedulerKey : NSObject, NSCopying {
override func isEqual(object: AnyObject?) -> Bool {
@ -77,11 +83,11 @@ public class CurrentThreadScheduler : ImmediateSchedulerType {
*/
public static private(set) var isScheduleRequired: Bool {
get {
let value = NSThread.getThreadLocalStorageValueForKey(CurrentThreadSchedulerKeyInstance) as CurrentThreadSchedulerKey?
let value: CurrentThreadSchedulerValue? = NSThread.getThreadLocalStorageValueForKey(CurrentThreadSchedulerKeyInstance)
return value == nil
}
set(isScheduleRequired) {
NSThread.setThreadLocalStorageValue(isScheduleRequired ? nil : CurrentThreadSchedulerKeyInstance, forKey: CurrentThreadSchedulerKeyInstance)
NSThread.setThreadLocalStorageValue(isScheduleRequired ? nil : CurrentThreadSchedulerValueInstance, forKey: CurrentThreadSchedulerKeyInstance)
}
}

View File

@ -9,6 +9,7 @@
import XCTest
import RxSwift
import RxTests
import Foundation
#if TRACE_RESOURCES
#elseif RELEASE
@ -28,11 +29,11 @@ class RxTest: XCTestCase {
static let subscribed = 200
static let disposed = 1000
}
func sleep(time: NSTimeInterval) {
NSRunLoop.currentRunLoop().runMode(NSDefaultRunLoopMode, beforeDate: NSDate(timeIntervalSinceNow: time))
}
private var startResourceCount: Int32 = 0
var accumulateStatistics: Bool {
@ -97,7 +98,7 @@ class RxTest: XCTestCase {
func tearDown() {
tearDownActions()
}
#else
#else
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()