Update pod RxSwift, RxCocoa to 4.5.0

This commit is contained in:
Qiu Yuzhou
2019-09-10 14:30:51 +08:00
parent 075949cdcb
commit 72c643eab2
238 changed files with 9425 additions and 4826 deletions

71
Pods/RxSwift/Platform/AtomicInt.swift generated Normal file
View File

@ -0,0 +1,71 @@
//
// AtomicInt.swift
// Platform
//
// Created by Krunoslav Zaher on 10/28/18.
// Copyright © 2018 Krunoslav Zaher. All rights reserved.
//
import class Foundation.NSLock
final class AtomicInt: NSLock {
fileprivate var value: Int32
public init(_ value: Int32 = 0) {
self.value = value
}
}
@discardableResult
@inline(__always)
func add(_ this: AtomicInt, _ value: Int32) -> Int32 {
this.lock()
let oldValue = this.value
this.value += value
this.unlock()
return oldValue
}
@discardableResult
@inline(__always)
func sub(_ this: AtomicInt, _ value: Int32) -> Int32 {
this.lock()
let oldValue = this.value
this.value -= value
this.unlock()
return oldValue
}
@discardableResult
@inline(__always)
func fetchOr(_ this: AtomicInt, _ mask: Int32) -> Int32 {
this.lock()
let oldValue = this.value
this.value |= mask
this.unlock()
return oldValue
}
@inline(__always)
func load(_ this: AtomicInt) -> Int32 {
this.lock()
let oldValue = this.value
this.unlock()
return oldValue
}
@discardableResult
@inline(__always)
func increment(_ this: AtomicInt) -> Int32 {
return add(this, 1)
}
@discardableResult
@inline(__always)
func decrement(_ this: AtomicInt) -> Int32 {
return sub(this, 1)
}
@inline(__always)
func isFlagSet(_ this: AtomicInt, _ mask: Int32) -> Bool {
return (load(this) & mask) != 0
}

View File

@ -25,7 +25,7 @@ Data structure that represents a bag of elements typed `T`.
Single element can be stored multiple times.
Time and space complexity of insertion an deletion is O(n).
Time and space complexity of insertion and deletion is O(n).
It is suitable for storing small number of elements.
*/
@ -40,14 +40,14 @@ struct Bag<T> : CustomDebugStringConvertible {
// data
// first fill inline variables
var _key0: BagKey? = nil
var _value0: T? = nil
var _key0: BagKey?
var _value0: T?
// then fill "array dictionary"
var _pairs = ContiguousArray<Entry>()
// last is sparse dictionary
var _dictionary: [BagKey : T]? = nil
var _dictionary: [BagKey: T]?
var _onlyFastPath = true
@ -122,12 +122,10 @@ struct Bag<T> : CustomDebugStringConvertible {
return existingObject
}
for i in 0 ..< _pairs.count {
if _pairs[i].key == key {
let value = _pairs[i].value
_pairs.remove(at: i)
return value
}
for i in 0 ..< _pairs.count where _pairs[i].key == key {
let value = _pairs[i].value
_pairs.remove(at: i)
return value
}
return nil
@ -173,9 +171,15 @@ extension Bag {
}
extension BagKey: Hashable {
#if swift(>=4.2)
func hash(into hasher: inout Hasher) {
hasher.combine(rawValue)
}
#else
var hashValue: Int {
return rawValue.hashValue
}
#endif
}
func ==(lhs: BagKey, rhs: BagKey) -> Bool {

View File

@ -52,11 +52,7 @@ struct PriorityQueue<Element> {
private mutating func removeAt(_ index: Int) {
let removingLast = index == _elements.count - 1
if !removingLast {
#if swift(>=3.2)
_elements.swapAt(index, _elements.count - 1)
#else
swap(&_elements[index], &_elements[_elements.count - 1])
#endif
}
_ = _elements.popLast()
@ -76,11 +72,7 @@ struct PriorityQueue<Element> {
while unbalancedIndex > 0 {
let parentIndex = (unbalancedIndex - 1) / 2
guard _hasHigherPriority(_elements[unbalancedIndex], _elements[parentIndex]) else { break }
#if swift(>=3.2)
_elements.swapAt(unbalancedIndex, parentIndex)
#else
swap(&_elements[unbalancedIndex], &_elements[parentIndex])
#endif
unbalancedIndex = parentIndex
}
}
@ -105,12 +97,8 @@ struct PriorityQueue<Element> {
}
guard highestPriorityIndex != unbalancedIndex else { break }
#if swift(>=3.2)
_elements.swapAt(highestPriorityIndex, unbalancedIndex)
#else
swap(&_elements[highestPriorityIndex], &_elements[unbalancedIndex])
#endif
unbalancedIndex = highestPriorityIndex
}
}

View File

@ -10,34 +10,10 @@
import Darwin
import class Foundation.Thread
import func Foundation.OSAtomicCompareAndSwap32Barrier
import func Foundation.OSAtomicIncrement32Barrier
import func Foundation.OSAtomicDecrement32Barrier
import protocol Foundation.NSCopying
typealias AtomicInt = Int32
fileprivate func castToUInt32Pointer(_ pointer: UnsafeMutablePointer<Int32>) -> UnsafeMutablePointer<UInt32> {
let raw = UnsafeMutableRawPointer(pointer)
return raw.assumingMemoryBound(to: UInt32.self)
}
let AtomicCompareAndSwap = OSAtomicCompareAndSwap32Barrier
let AtomicIncrement = OSAtomicIncrement32Barrier
let AtomicDecrement = OSAtomicDecrement32Barrier
func AtomicOr(_ mask: UInt32, _ theValue : UnsafeMutablePointer<Int32>) -> Int32 {
return OSAtomicOr32OrigBarrier(mask, castToUInt32Pointer(theValue))
}
func AtomicFlagSet(_ mask: UInt32, _ theValue : UnsafeMutablePointer<Int32>) -> Bool {
// just used to create a barrier
OSAtomicXor32OrigBarrier(0, castToUInt32Pointer(theValue))
return (theValue.pointee & Int32(mask)) != 0
}
extension Thread {
static func setThreadLocalStorageValue<T: AnyObject>(_ value: T?, forKey key: NSCopying
) {
static func setThreadLocalStorageValue<T: AnyObject>(_ value: T?, forKey key: NSCopying) {
let currentThread = Thread.current
let threadDictionary = currentThread.threadDictionary
@ -47,8 +23,8 @@
else {
threadDictionary[key] = nil
}
}
static func getThreadLocalStorageValueForKey<T>(_ key: NSCopying) -> T? {
let currentThread = Thread.current
let threadDictionary = currentThread.threadDictionary
@ -57,10 +33,4 @@
}
}
extension AtomicInt {
func valueSnapshot() -> Int32 {
return self
}
}
#endif

View File

@ -8,76 +8,8 @@
#if os(Linux)
import XCTest
import Glibc
import SwiftShims
import class Foundation.Thread
final class AtomicInt {
typealias IntegerLiteralType = Int
fileprivate var value: Int32 = 0
fileprivate var _lock = RecursiveLock()
func lock() {
_lock.lock()
}
func unlock() {
_lock.unlock()
}
func valueSnapshot() -> Int32 {
return value
}
}
extension AtomicInt: ExpressibleByIntegerLiteral {
convenience init(integerLiteral value: Int) {
self.init()
self.value = Int32(value)
}
}
func >(lhs: AtomicInt, rhs: Int32) -> Bool {
return lhs.value > rhs
}
func ==(lhs: AtomicInt, rhs: Int32) -> Bool {
return lhs.value == rhs
}
func AtomicFlagSet(_ mask: UInt32, _ atomic: inout AtomicInt) -> Bool {
atomic.lock(); defer { atomic.unlock() }
return (atomic.value & Int32(mask)) != 0
}
func AtomicOr(_ mask: UInt32, _ atomic: inout AtomicInt) -> Int32 {
atomic.lock(); defer { atomic.unlock() }
let value = atomic.value
atomic.value |= Int32(mask)
return value
}
func AtomicIncrement(_ atomic: inout AtomicInt) -> Int32 {
atomic.lock(); defer { atomic.unlock() }
atomic.value += 1
return atomic.value
}
func AtomicDecrement(_ atomic: inout AtomicInt) -> Int32 {
atomic.lock(); defer { atomic.unlock() }
atomic.value -= 1
return atomic.value
}
func AtomicCompareAndSwap(_ l: Int32, _ r: Int32, _ atomic: inout AtomicInt) -> Bool {
atomic.lock(); defer { atomic.unlock() }
if atomic.value == l {
atomic.value = r
return true
}
return false
}
extension Thread {
static func setThreadLocalStorageValue<T: AnyObject>(_ value: T?, forKey key: String) {