From 1b26e9bbd622832a9ed5eb4e9ff59ae0e57f5984 Mon Sep 17 00:00:00 2001 From: Krunoslav Zaher Date: Sun, 10 Jan 2016 20:57:55 +0100 Subject: [PATCH] Declares `SpinLock` as `NSRecursiveLock` on `Darwin` because of `https://lists.swift.org/pipermail/swift-dev/Week-of-Mon-20151214/000321.html`. --- RxSwift/Concurrency/Lock.swift | 41 ++-------------------------------- 1 file changed, 2 insertions(+), 39 deletions(-) diff --git a/RxSwift/Concurrency/Lock.swift b/RxSwift/Concurrency/Lock.swift index ff039362..048ac50b 100644 --- a/RxSwift/Concurrency/Lock.swift +++ b/RxSwift/Concurrency/Lock.swift @@ -63,46 +63,9 @@ protocol Lock { } } #else - /** - Simple wrapper for spin lock. - */ - struct SpinLock { - private var _lock = OS_SPINLOCK_INIT - init() { - - } - - mutating func lock() { - OSSpinLockLock(&_lock) - } - - mutating func unlock() { - OSSpinLockUnlock(&_lock) - } - - mutating func performLocked(@noescape action: () -> Void) { - OSSpinLockLock(&_lock) - action() - OSSpinLockUnlock(&_lock) - } - - mutating func calculateLocked(@noescape action: () -> T) -> T { - OSSpinLockLock(&_lock) - let result = action() - OSSpinLockUnlock(&_lock) - return result - } - - mutating func calculateLockedOrFail(@noescape action: () throws -> T) throws -> T { - OSSpinLockLock(&_lock) - defer { - OSSpinLockUnlock(&_lock) - } - let result = try action() - return result - } - } + // https://lists.swift.org/pipermail/swift-dev/Week-of-Mon-20151214/000321.html + typealias SpinLock = NSRecursiveLock #endif extension NSRecursiveLock : Lock {