Switch from OSAllocatedUnfairLock to Mutex.

This commit is contained in:
Brent Simmons committed 2026-10-21 19:08:32 -07:00
1 parent 3baacbbad1
commit a207f3411e
4 files changed
+9 -7

No files matched your search

@@ -7,7 +7,7 @@
//
import Foundation
import os
import Synchronization
public final class ArticleStatus: Hashable, Sendable {
@@ -27,7 +27,7 @@ public final class ArticleStatus: Hashable, Sendable {
var starred: Bool
}
private let state: OSAllocatedUnfairLock<State>
private let state: Mutex<State>
public var read: Bool {
get {
@@ -49,7 +49,7 @@ public final class ArticleStatus: Hashable, Sendable {
public init(articleID: String, read: Bool, starred: Bool, dateArrived: Date) {
self.articleID = articleID
self.state = OSAllocatedUnfairLock(initialState: State(read: read, starred: starred))
self.state = Mutex(State(read: read, starred: starred))
self.dateArrived = dateArrived
}
@@ -6,7 +6,7 @@
//
import Foundation
import os
import Synchronization
import RSCore
/// Caches `Author` values by `authorID` so articles by the same author share
@@ -15,7 +15,7 @@ public final class AuthorCache: Sendable {
public static let shared = AuthorCache()
private let cache = OSAllocatedUnfairLock<[String: Author]>(initialState: [:])
private let cache = Mutex<[String: Author]>([:])
init() {
if !Platform.isRunningUnitTests {
@@ -12,6 +12,7 @@ import RSCore
import RSDatabase
import RSDatabaseObjC
import RSParser
import Synchronization
import Articles
final class ArticlesTable: DatabaseTable, Sendable {
@@ -22,7 +23,7 @@ final class ArticlesTable: DatabaseTable, Sendable {
private let statusesTable: StatusesTable
private let searchTable: SearchTable
private let retentionStyle: ArticlesDatabase.RetentionStyle
private let articlesCache = OSAllocatedUnfairLock(initialState: [String: Article]())
private let articlesCache = Mutex([String: Article]())
private static let logger = Logger(subsystem: Logger.nnwSubsystem, category: "ArticlesTable")
private static let signposter = OSSignposter(subsystem: Logger.nnwSubsystem, category: .pointsOfInterest)
@@ -11,6 +11,7 @@ import os
import RSCore
import RSDatabase
import RSDatabaseObjC
import Synchronization
import Articles
// Article->ArticleStatus is a to-one relationship.
@@ -325,7 +326,7 @@ private final class StatusCache: Sendable {
var dictionary = [String: ArticleStatus]()
}
private let state = OSAllocatedUnfairLock(initialState: State())
private let state = Mutex(State())
func addStatusIfNotCached(_ status: ArticleStatus) {
addIfNotCached(Set([status]))