Files
ShadowsocksX-NG/Pods/RxCocoa/Platform/Platform.Linux.swift

38 lines
964 B
Swift
Raw Permalink Normal View History

2017-03-17 23:08:52 +08:00
//
// Platform.Linux.swift
// Platform
//
// Created by Krunoslav Zaher on 12/29/15.
// Copyright © 2015 Krunoslav Zaher. All rights reserved.
//
#if os(Linux)
2017-03-20 21:26:25 +08:00
import class Foundation.Thread
2017-03-17 23:08:52 +08:00
extension Thread {
static func setThreadLocalStorageValue<T: AnyObject>(_ value: T?, forKey key: String) {
let currentThread = Thread.current
var threadDictionary = currentThread.threadDictionary
if let newValue = value {
threadDictionary[key] = newValue
}
else {
threadDictionary[key] = nil
}
currentThread.threadDictionary = threadDictionary
}
static func getThreadLocalStorageValueForKey<T: AnyObject>(_ key: String) -> T? {
let currentThread = Thread.current
let threadDictionary = currentThread.threadDictionary
return threadDictionary[key] as? T
}
}
#endif