os_unfair_lock OS_UNFAIR_LOCK_INIT os_unfair_lock_t os_unfair_lock_trylock os_unfair_lock_unlock os_unfair_lock_assert_owner os_unfair_lock_assert_not_owner extern void os_unfair_lock_lock(os_unfair_lock_t lock);lockA pointer to the unfair lock to be locked.
Consider a lock’s data to be opaque and implementation-defined. Locks contain thread-ownership information that the system may use to attempt to resolve priority inversions.
A lock must be unlocked only from the same thread in which it was locked. Attempting to unlock from a different thread causes a runtime error.
A lock must not be accessed from multiple processes or threads via shared or multiply-mapped memory, because the lock implementation relies on the address of the lock value and owning process.
Note
This is a replacement for the deprecated OSSpin. This function doesn’t spin on contention, but instead waits in the kernel to be awoken by an unlock. Like OSSpin, this function does not enforce fairness or lock ordering—for example, an unlocker could potentially reacquire the lock immediately, before an awoken waiter gets an opportunity to attempt to acquire the lock. This may be advantageous for performance reasons, but also makes starvation of waiters a possibility.
os_unfair_lock OS_UNFAIR_LOCK_INIT os_unfair_lock_t os_unfair_lock_trylock os_unfair_lock_unlock os_unfair_lock_assert_owner os_unfair_lock_assert_not_owner