From 3dfe0595f6010345fc6a14934bb1b830caf5b5ac Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Wed, 21 Oct 2026 19:10:31 -0700 Subject: [PATCH] Switch from OSAllocatedUnfairLock to Mutex. --- .../Sources/HTMLMetadata/HTMLMetadataDownloader.swift | 5 +++-- Modules/Images/Sources/Images/IconImage.swift | 4 ++-- Modules/RSWeb/Sources/RSWeb/NetworkMonitor.swift | 4 ++-- .../RSWeb/Sources/RSWeb/WebServices/TestingURLProtocol.swift | 4 ++-- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Modules/HTMLMetadata/Sources/HTMLMetadata/HTMLMetadataDownloader.swift b/Modules/HTMLMetadata/Sources/HTMLMetadata/HTMLMetadataDownloader.swift index 5e14cfc35..1c04231ca 100644 --- a/Modules/HTMLMetadata/Sources/HTMLMetadata/HTMLMetadataDownloader.swift +++ b/Modules/HTMLMetadata/Sources/HTMLMetadata/HTMLMetadataDownloader.swift @@ -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) diff --git a/Modules/Images/Sources/Images/IconImage.swift b/Modules/Images/Sources/Images/IconImage.swift index 2174033f8..10ad4f1ef 100644 --- a/Modules/Images/Sources/Images/IconImage.swift +++ b/Modules/Images/Sources/Images/IconImage.swift @@ -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(initialState: nil) + private let cachedLuminanceType = Mutex(nil) private static let luminanceQueue = DispatchQueue(label: "com.ranchero.NetNewsWire.IconImage.luminance", qos: .utility, attributes: .concurrent) public var isDark: Bool { diff --git a/Modules/RSWeb/Sources/RSWeb/NetworkMonitor.swift b/Modules/RSWeb/Sources/RSWeb/NetworkMonitor.swift index 81ce508ff..3f6480a0a 100644 --- a/Modules/RSWeb/Sources/RSWeb/NetworkMonitor.swift +++ b/Modules/RSWeb/Sources/RSWeb/NetworkMonitor.swift @@ -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(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. diff --git a/Modules/RSWeb/Sources/RSWeb/WebServices/TestingURLProtocol.swift b/Modules/RSWeb/Sources/RSWeb/WebServices/TestingURLProtocol.swift index 0a02e8c53..594ef4447 100644 --- a/Modules/RSWeb/Sources/RSWeb/WebServices/TestingURLProtocol.swift +++ b/Modules/RSWeb/Sources/RSWeb/WebServices/TestingURLProtocol.swift @@ -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"