Merge pull request #3111 from heckj/unsafe_os_unfair_lock

replacing os_unfair_lock with NSLock
This commit is contained in:
Brent Simmons 2021-05-10 11:22:20 -07:00 committed by GitHub
commit a6a641d1c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 6 deletions

View File

@ -14,12 +14,11 @@ import RSCore
// * Collisions arent going to happen with feed data // * Collisions arent going to happen with feed data
private var databaseIDCache = [String: String]() private var databaseIDCache = [String: String]()
private var databaseIDCacheLock = os_unfair_lock_s() private var databaseIDCacheLock = NSLock()
public func databaseIDWithString(_ s: String) -> String { public func databaseIDWithString(_ s: String) -> String {
os_unfair_lock_lock(&databaseIDCacheLock) databaseIdCacheLock.lock()
defer { defer {
os_unfair_lock_unlock(&databaseIDCacheLock) databaseIdCacheLock.unlock()
} }
if let identifier = databaseIDCache[s] { if let identifier = databaseIDCache[s] {