os_unfair_lock_trylock
Locks an unfair lock if it is not already locked.
Declaration
extern bool os_unfair_lock_trylock(os_unfair_lock_t lock);Parameters
- lock:
A pointer to the unfair lock to be locked.
Return Value
true if the lock was successfully locked, or false if the lock was already locked.
Discussion
If this function returns false, you must either proceed without having acquired the lock or call os_unfair_lock_lock directly. Do not attempt to call this function within a retry loop; os_unfair_lock_lock accomplishes the same task, without hiding the lock waiter from the system or preventing resolution of priority inversions.