服务商获取权限失败的话retry,更换了首页的背景图
This commit is contained in:
67
Pods/Alamofire/Source/Protected.swift
generated
67
Pods/Alamofire/Source/Protected.swift
generated
@@ -49,13 +49,7 @@ extension Lock {
|
||||
}
|
||||
}
|
||||
|
||||
#if os(Linux) || os(Windows)
|
||||
|
||||
extension NSLock: Lock {}
|
||||
|
||||
#endif
|
||||
|
||||
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
|
||||
#if canImport(Darwin)
|
||||
/// An `os_unfair_lock` wrapper.
|
||||
final class UnfairLock: Lock {
|
||||
private let unfairLock: os_unfair_lock_t
|
||||
@@ -78,41 +72,35 @@ final class UnfairLock: Lock {
|
||||
os_unfair_lock_unlock(unfairLock)
|
||||
}
|
||||
}
|
||||
|
||||
#elseif canImport(Foundation)
|
||||
extension NSLock: Lock {}
|
||||
#else
|
||||
#error("This platform needs a Lock-conforming type without Foundation.")
|
||||
#endif
|
||||
|
||||
/// A thread-safe wrapper around a value.
|
||||
@propertyWrapper
|
||||
@dynamicMemberLookup
|
||||
final class Protected<T> {
|
||||
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
|
||||
final class Protected<Value> {
|
||||
#if canImport(Darwin)
|
||||
private let lock = UnfairLock()
|
||||
#elseif os(Linux) || os(Windows)
|
||||
#elseif canImport(Foundation)
|
||||
private let lock = NSLock()
|
||||
#else
|
||||
#error("This platform needs a Lock-conforming type without Foundation.")
|
||||
#endif
|
||||
private var value: T
|
||||
private var value: Value
|
||||
|
||||
init(_ value: T) {
|
||||
init(_ value: Value) {
|
||||
self.value = value
|
||||
}
|
||||
|
||||
/// The contained value. Unsafe for anything more than direct read or write.
|
||||
var wrappedValue: T {
|
||||
get { lock.around { value } }
|
||||
set { lock.around { value = newValue } }
|
||||
}
|
||||
|
||||
var projectedValue: Protected<T> { self }
|
||||
|
||||
init(wrappedValue: T) {
|
||||
value = wrappedValue
|
||||
}
|
||||
|
||||
/// Synchronously read or transform the contained value.
|
||||
///
|
||||
/// - Parameter closure: The closure to execute.
|
||||
///
|
||||
/// - Returns: The return value of the closure passed.
|
||||
func read<U>(_ closure: (T) throws -> U) rethrows -> U {
|
||||
func read<U>(_ closure: (Value) throws -> U) rethrows -> U {
|
||||
try lock.around { try closure(self.value) }
|
||||
}
|
||||
|
||||
@@ -122,21 +110,28 @@ final class Protected<T> {
|
||||
///
|
||||
/// - Returns: The modified value.
|
||||
@discardableResult
|
||||
func write<U>(_ closure: (inout T) throws -> U) rethrows -> U {
|
||||
func write<U>(_ closure: (inout Value) throws -> U) rethrows -> U {
|
||||
try lock.around { try closure(&self.value) }
|
||||
}
|
||||
|
||||
subscript<Property>(dynamicMember keyPath: WritableKeyPath<T, Property>) -> Property {
|
||||
/// Synchronously update the protected value.
|
||||
///
|
||||
/// - Parameter value: The `Value`.
|
||||
func write(_ value: Value) {
|
||||
write { $0 = value }
|
||||
}
|
||||
|
||||
subscript<Property>(dynamicMember keyPath: WritableKeyPath<Value, Property>) -> Property {
|
||||
get { lock.around { value[keyPath: keyPath] } }
|
||||
set { lock.around { value[keyPath: keyPath] = newValue } }
|
||||
}
|
||||
|
||||
subscript<Property>(dynamicMember keyPath: KeyPath<T, Property>) -> Property {
|
||||
subscript<Property>(dynamicMember keyPath: KeyPath<Value, Property>) -> Property {
|
||||
lock.around { value[keyPath: keyPath] }
|
||||
}
|
||||
}
|
||||
|
||||
extension Protected where T == Request.MutableState {
|
||||
extension Protected where Value == Request.MutableState {
|
||||
/// Attempts to transition to the passed `State`.
|
||||
///
|
||||
/// - Parameter state: The `State` to attempt transition to.
|
||||
@@ -159,3 +154,15 @@ extension Protected where T == Request.MutableState {
|
||||
lock.around { perform(value.state) }
|
||||
}
|
||||
}
|
||||
|
||||
extension Protected: Equatable where Value: Equatable {
|
||||
static func ==(lhs: Protected<Value>, rhs: Protected<Value>) -> Bool {
|
||||
lhs.read { left in rhs.read { right in left == right }}
|
||||
}
|
||||
}
|
||||
|
||||
extension Protected: Hashable where Value: Hashable {
|
||||
func hash(into hasher: inout Hasher) {
|
||||
read { hasher.combine($0) }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user