Created
March 2, 2022 12:56
-
-
Save pronebird/6022f387bccf89adeaf29f92f453c124 to your computer and use it in GitHub Desktop.
Wrapper type for os_unfair_lock
This file contains hidden or 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
class UnfairLock: NSLocking { | |
private var _lock = os_unfair_lock() | |
func lock() { | |
os_unfair_lock_lock(&_lock) | |
} | |
func unlock() { | |
os_unfair_lock_unlock(&_lock) | |
} | |
func `try`() -> Bool { | |
return os_unfair_lock_trylock(&_lock) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment