Sometimes they can be handy!
Spinlocks are the wrong answer is almost all circumstances. Blocking locks have a fast path that makes them as efficient as spinlocks in the uncontested case, and spinlocks behave very badly in the contested case. Specifically, spinlocks have no ability to deal with priority inversions.
You should take a look at the comments in the (now deprecated)
<libkern/OSSpinLockDeprecated.h>
and (its replacement)
<os/lock.h>
.
I don't understand the context in which all NSNotifications are delivered.
In the classic NSNotification architecture, notifications are synchronous and occur on the thread of the caller. That is, the thread that calls
-postNotification:
actually calls each of the observers in turn. This can be confusing but it’s a super useful property, especially if the poster guarantees to post on the main thread.
Share and Enjoy
—
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"