mirror of
https://github.com/ReactiveX/RxSwift.git
synced 2024-10-04 22:17:41 +03:00
a1a2f00c7a
In order to support `-enable-library-evolution` and `swiftinteface` files, we have to use non-scoped imports. I've filed an upstream bug to track this https://bugs.swift.org/browse/SR-11782 This is a step towards https://github.com/ReactiveX/RxSwift/issues/2026
36 lines
951 B
Swift
36 lines
951 B
Swift
//
|
|
// Platform.Darwin.swift
|
|
// Platform
|
|
//
|
|
// Created by Krunoslav Zaher on 12/29/15.
|
|
// Copyright © 2015 Krunoslav Zaher. All rights reserved.
|
|
//
|
|
|
|
#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
|
|
|
|
import Darwin
|
|
import Foundation
|
|
|
|
extension Thread {
|
|
static func setThreadLocalStorageValue<T: AnyObject>(_ value: T?, forKey key: NSCopying) {
|
|
let currentThread = Thread.current
|
|
let threadDictionary = currentThread.threadDictionary
|
|
|
|
if let newValue = value {
|
|
threadDictionary[key] = newValue
|
|
}
|
|
else {
|
|
threadDictionary[key] = nil
|
|
}
|
|
}
|
|
|
|
static func getThreadLocalStorageValueForKey<T>(_ key: NSCopying) -> T? {
|
|
let currentThread = Thread.current
|
|
let threadDictionary = currentThread.threadDictionary
|
|
|
|
return threadDictionary[key] as? T
|
|
}
|
|
}
|
|
|
|
#endif
|