Switch from OSAllocatedUnfairLock to Mutex.

This commit is contained in:
Brent Simmons committed 2026-10-21 19:10:31 -07:00
1 parent a207f3411e
commit 3dfe0595f6
4 files changed
+9 -8

No files matched your search

@@ -11,6 +11,7 @@ import os
import RSCore
import RSParser
import RSWeb
import Synchronization
import ActivityLog
nonisolated public final class HTMLMetadataDownloader: Sendable {
@@ -21,10 +22,10 @@ nonisolated public final class HTMLMetadataDownloader: Sendable {
private static let hoursBetweenAttempts = 3
private let attemptDates = OSAllocatedUnfairLock(initialState: [String: Date]())
private let attemptDates = Mutex([String: Date]())
/// In-memory mirror so `cachedMetadata(for:)` can answer synchronously.
private let cache = OSAllocatedUnfairLock(initialState: [String: HTMLMetadataRecord]())
private let cache = Mutex([String: HTMLMetadataRecord]())
init() {
NotificationCenter.default.addObserver(self, selector: #selector(handleAppDidGoToBackground(_:)), name: .appDidGoToBackground, object: nil)
@@ -11,7 +11,7 @@ import AppKit
#else
import UIKit
#endif
import os
import Synchronization
import RSCore
extension RSImage {
@@ -24,7 +24,7 @@ public final class IconImage: @unchecked Sendable {
public let isBackgroundSuppressed: Bool
public let preferredColor: RSColor?
private let cachedLuminanceType = OSAllocatedUnfairLock<ImageLuminanceType?>(initialState: nil)
private let cachedLuminanceType = Mutex<ImageLuminanceType?>(nil)
private static let luminanceQueue = DispatchQueue(label: "com.ranchero.NetNewsWire.IconImage.luminance", qos: .utility, attributes: .concurrent)
public var isDark: Bool {
@@ -7,7 +7,7 @@
import Foundation
import Network
import os
import Synchronization
nonisolated public final class NetworkMonitor: Sendable {
public static let shared = NetworkMonitor()
@@ -22,7 +22,7 @@ nonisolated public final class NetworkMonitor: Sendable {
var isConstrained = false
}
private let state = OSAllocatedUnfairLock<State>(initialState: State())
private let state = Mutex(State())
/// `true` until `NWPathMonitor` delivers its first path, so callers attempt
/// network work rather than skip it on an answer we don't have yet.
@@ -6,7 +6,7 @@
//
import Foundation
import os
import Synchronization
public final class TestingURLProtocol: URLProtocol {
@@ -49,7 +49,7 @@ public final class TestingURLProtocol: URLProtocol {
/// Maps a test ID to its state. Requests from a session built outside a
/// `currentTestID` scope use `sharedTestID`.
private static let testStates = OSAllocatedUnfairLock<[String: TestState]>(initialState: [:])
private static let testStates = Mutex<[String: TestState]>([:])
private static let sharedTestID = "shared"