Simpler and thread-safer implementation with OSSpinLock.