os_unfair_lock
Peter Steinberger measured the new os_unfair_lock
against OSSpinLock
, pthread_mutex
, NSLock
, dispatch queues, and @synchronized
.
Pierre Habouzit (via David Smith):
Apple’s libplatform is now OSS too with user-land os_unfair_lock (os/lock.c) in all its strict glory.
If you use it from Swift, you have to be careful, because it’s a struct and Swift doesn’t prevent you from copying or moving it around, which normally would be an error.
Previously: OSSpinLock Is Unsafe, Mutexes and Closure Capture in Swift.
2 Comments
[…] os_unfair_lock is the new synchronization hotness! […]
Stay up-to-date by subscribing to the Comments RSS Feed for this post.
From what I've seen in some crash reports, os_unfair_lock is not happy with forked processes.
e.g.
BUG IN CLIENT OF LIBPLATFORM: os_unfair_lock is corrupt.
Moving to posix_spawn seems to make it happier.