diff --git a/Commons/Sources/Commons/FifoCache.swift b/Commons/Sources/Commons/FifoCache.swift index 82806a41..ea3db730 100644 --- a/Commons/Sources/Commons/FifoCache.swift +++ b/Commons/Sources/Commons/FifoCache.swift @@ -7,11 +7,15 @@ import Foundation public final class FifoCache { - public init(count: Int) { + public init(count: Int, queueQos: DispatchQoS) { self.count = count self.keyWriteIndex = 0 self.keys = Array(repeating: nil, count: count) self.storage = Dictionary(minimumCapacity: count) + self.queue = DispatchQueue( + label: "\(String(reflecting: FifoCache.self))-\(UUID().uuidString)", + qos: queueQos + ) } public func set(_ value: Value, forKey key: Key) { @@ -32,5 +36,5 @@ public final class FifoCache { private var keyWriteIndex: Int private var storage: Dictionary - private let queue = DispatchQueue(label: "FifoCache-\(UUID().uuidString)", qos: .userInteractive) + private let queue: DispatchQueue } diff --git a/NvimView/Sources/NvimView/ColorUtils.swift b/NvimView/Sources/NvimView/ColorUtils.swift index ad1a27bf..0f40d64a 100644 --- a/NvimView/Sources/NvimView/ColorUtils.swift +++ b/NvimView/Sources/NvimView/ColorUtils.swift @@ -44,5 +44,5 @@ final class ColorUtils { } } -private let colorCache = FifoCache(count: 500) -private let cgColorCache = FifoCache(count: 500) +private let colorCache = FifoCache(count: 500, queueQos: .userInteractive) +private let cgColorCache = FifoCache(count: 500, queueQos: .userInteractive) diff --git a/NvimView/Sources/NvimView/FontUtils.swift b/NvimView/Sources/NvimView/FontUtils.swift index 6c2740f7..375b1126 100644 --- a/NvimView/Sources/NvimView/FontUtils.swift +++ b/NvimView/Sources/NvimView/FontUtils.swift @@ -77,5 +77,8 @@ final class FontUtils { } } -private let fontCache = FifoCache(count: 100) -private let cellSizeWithDefaultLinespacingCache = FifoCache(count: 100) +private let fontCache = FifoCache(count: 100, queueQos: .userInteractive) +private let cellSizeWithDefaultLinespacingCache = FifoCache( + count: 100, + queueQos: .userInteractive +) diff --git a/NvimView/Sources/NvimView/Typesetter.swift b/NvimView/Sources/NvimView/Typesetter.swift index 3fbb0439..be32ad9f 100644 --- a/NvimView/Sources/NvimView/Typesetter.swift +++ b/NvimView/Sources/NvimView/Typesetter.swift @@ -272,7 +272,10 @@ final class Typesetter { } } - private let ctRunsCache = FifoCache, CtRunsAndFont>(count: 5000) + private let ctRunsCache = FifoCache, CtRunsAndFont>( + count: 5000, + queueQos: .userInteractive + ) private let log = OSLog(subsystem: Defs.loggerSubsystem, category: Defs.LoggerCategory.view)