Created
April 14, 2016 09:46
-
-
Save comfly/15ced99cb4f2a5e1809a1c0c7adfe8b3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public final class SpinLock { | |
private var lock: OSSpinLock = OS_SPINLOCK_INIT | |
public func locked<A>(@noescape f: () throws -> A) rethrows -> A { | |
OSSpinLockLock(&lock) | |
defer { OSSpinLockUnlock(&lock) } | |
return try f() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment