Files
OrderScheduling/Pods/RxSwift/RxSwift/Concurrency/Lock.swift
DDIsFriend f0e8a1709d initial
2023-08-18 17:28:57 +08:00

24 lines
499 B
Swift

//
// Lock.swift
// RxSwift
//
// Created by Krunoslav Zaher on 3/31/15.
// Copyright © 2015 Krunoslav Zaher. All rights reserved.
//
protocol Lock {
func lock()
func unlock()
}
// https://lists.swift.org/pipermail/swift-dev/Week-of-Mon-20151214/000321.html
typealias SpinLock = RecursiveLock
extension RecursiveLock : Lock {
@inline(__always)
final func performLocked<T>(_ action: () -> T) -> T {
self.lock(); defer { self.unlock() }
return action()
}
}