Replaced usage of dispatch_semaphore with OSSpinLock.