Update outdated pods.
This commit is contained in:
24
Pods/RxCocoa/Platform/DataStructures/Bag.swift
generated
24
Pods/RxCocoa/Platform/DataStructures/Bag.swift
generated
@ -6,7 +6,6 @@
|
||||
// Copyright © 2015 Krunoslav Zaher. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Swift
|
||||
|
||||
let arrayDictionaryMaxSize = 30
|
||||
@ -44,6 +43,9 @@ struct Bag<T> : CustomDebugStringConvertible {
|
||||
var _key0: BagKey? = nil
|
||||
var _value0: T? = nil
|
||||
|
||||
// then fill "array dictionary"
|
||||
var _pairs = ContiguousArray<Entry>()
|
||||
|
||||
// last is sparse dictionary
|
||||
var _dictionary: [BagKey : T]? = nil
|
||||
|
||||
@ -77,6 +79,11 @@ struct Bag<T> : CustomDebugStringConvertible {
|
||||
return key
|
||||
}
|
||||
|
||||
if _pairs.count < arrayDictionaryMaxSize {
|
||||
_pairs.append(key: key, value: element)
|
||||
return key
|
||||
}
|
||||
|
||||
if _dictionary == nil {
|
||||
_dictionary = [:]
|
||||
}
|
||||
@ -89,7 +96,7 @@ struct Bag<T> : CustomDebugStringConvertible {
|
||||
/// - returns: Number of elements in bag.
|
||||
var count: Int {
|
||||
let dictionaryCount: Int = _dictionary?.count ?? 0
|
||||
return (_value0 != nil ? 1 : 0) + dictionaryCount
|
||||
return (_value0 != nil ? 1 : 0) + _pairs.count + dictionaryCount
|
||||
}
|
||||
|
||||
/// Removes all elements from bag and clears capacity.
|
||||
@ -97,6 +104,7 @@ struct Bag<T> : CustomDebugStringConvertible {
|
||||
_key0 = nil
|
||||
_value0 = nil
|
||||
|
||||
_pairs.removeAll(keepingCapacity: false)
|
||||
_dictionary?.removeAll(keepingCapacity: false)
|
||||
}
|
||||
|
||||
@ -118,6 +126,14 @@ 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
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@ -148,6 +164,10 @@ extension Bag {
|
||||
action(value0)
|
||||
}
|
||||
|
||||
for i in 0 ..< _pairs.count {
|
||||
action(_pairs[i].value)
|
||||
}
|
||||
|
||||
if dictionary?.count ?? 0 > 0 {
|
||||
for element in dictionary!.values {
|
||||
action(element)
|
||||
|
@ -6,8 +6,6 @@
|
||||
// Copyright © 2015 Krunoslav Zaher. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
/// Sequence that repeats `repeatedValue` infinite number of times.
|
||||
struct InfiniteSequence<E> : Sequence {
|
||||
typealias Element = E
|
||||
|
@ -6,8 +6,6 @@
|
||||
// Copyright © 2015 Krunoslav Zaher. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
struct PriorityQueue<Element> {
|
||||
private let _hasHigherPriority: (Element, Element) -> Bool
|
||||
private let _isEqual: (Element, Element) -> Bool
|
||||
|
2
Pods/RxCocoa/Platform/DataStructures/Queue.swift
generated
2
Pods/RxCocoa/Platform/DataStructures/Queue.swift
generated
@ -6,8 +6,6 @@
|
||||
// Copyright © 2015 Krunoslav Zaher. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
/**
|
||||
Data structure that represents queue.
|
||||
|
||||
|
@ -6,7 +6,6 @@
|
||||
// Copyright © 2016 Krunoslav Zaher. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Dispatch
|
||||
|
||||
extension DispatchQueue {
|
||||
|
23
Pods/RxCocoa/Platform/Platform.Darwin.swift
generated
23
Pods/RxCocoa/Platform/Platform.Darwin.swift
generated
@ -9,17 +9,34 @@
|
||||
#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
|
||||
|
||||
import Darwin
|
||||
import Foundation
|
||||
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: String
|
||||
static func setThreadLocalStorageValue<T: AnyObject>(_ value: T?, forKey key: NSCopying
|
||||
) {
|
||||
let currentThread = Thread.current
|
||||
let threadDictionary = currentThread.threadDictionary
|
||||
@ -32,7 +49,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
static func getThreadLocalStorageValueForKey<T>(_ key: String) -> T? {
|
||||
static func getThreadLocalStorageValueForKey<T>(_ key: NSCopying) -> T? {
|
||||
let currentThread = Thread.current
|
||||
let threadDictionary = currentThread.threadDictionary
|
||||
|
||||
|
20
Pods/RxCocoa/Platform/Platform.Linux.swift
generated
20
Pods/RxCocoa/Platform/Platform.Linux.swift
generated
@ -7,20 +7,16 @@
|
||||
//
|
||||
|
||||
#if os(Linux)
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// This is not the greatest API in the world, this is just a tribute.
|
||||
// !!! Proof of concept until libdispatch becomes operational. !!!
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
import Foundation
|
||||
import XCTest
|
||||
import Glibc
|
||||
import SwiftShims
|
||||
import class Foundation.Thread
|
||||
|
||||
final class AtomicInt {
|
||||
typealias IntegerLiteralType = Int
|
||||
fileprivate var value: Int32 = 0
|
||||
fileprivate var _lock = NSRecursiveLock()
|
||||
fileprivate var _lock = RecursiveLock()
|
||||
|
||||
func lock() {
|
||||
_lock.lock()
|
||||
@ -48,6 +44,18 @@
|
||||
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
|
||||
|
34
Pods/RxCocoa/Platform/RecursiveLock.swift
generated
Normal file
34
Pods/RxCocoa/Platform/RecursiveLock.swift
generated
Normal file
@ -0,0 +1,34 @@
|
||||
//
|
||||
// RecursiveLock.swift
|
||||
// Platform
|
||||
//
|
||||
// Created by Krunoslav Zaher on 12/18/16.
|
||||
// Copyright © 2016 Krunoslav Zaher. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
#if TRACE_RESOURCES
|
||||
class RecursiveLock: NSRecursiveLock {
|
||||
override init() {
|
||||
_ = Resources.incrementTotal()
|
||||
super.init()
|
||||
}
|
||||
|
||||
override func lock() {
|
||||
super.lock()
|
||||
_ = Resources.incrementTotal()
|
||||
}
|
||||
|
||||
override func unlock() {
|
||||
super.unlock()
|
||||
_ = Resources.decrementTotal()
|
||||
}
|
||||
|
||||
deinit {
|
||||
_ = Resources.decrementTotal()
|
||||
}
|
||||
}
|
||||
#else
|
||||
typealias RecursiveLock = NSRecursiveLock
|
||||
#endif
|
Reference in New Issue
Block a user