mirror of
https://github.com/pointfreeco/swift-composable-architecture.git
synced 2025-12-20 09:11:33 +01:00
* Failing test when reusing cancellation id. * wip * Clean up * update test * Update Tests/ComposableArchitectureTests/TimerTests.swift * move methods around * wip * more * wip Co-authored-by: Brandon Williams <mbw234@gmail.com>
20 lines
419 B
Swift
20 lines
419 B
Swift
import Foundation
|
|
|
|
extension UnsafeMutablePointer where Pointee == os_unfair_lock_s {
|
|
@inlinable @discardableResult
|
|
func sync<R>(_ work: () -> R) -> R {
|
|
os_unfair_lock_lock(self)
|
|
defer { os_unfair_lock_unlock(self) }
|
|
return work()
|
|
}
|
|
}
|
|
|
|
extension NSRecursiveLock {
|
|
@inlinable @discardableResult
|
|
func sync<R>(work: () -> R) -> R {
|
|
self.lock()
|
|
defer { self.unlock() }
|
|
return work()
|
|
}
|
|
}
|