mirror of
https://github.com/qvacua/vimr.git
synced 2024-12-24 06:12:45 +03:00
Make QOS of queue customizable in FifoCache
This commit is contained in:
parent
4e60d5878b
commit
9080ad8b5c
@ -7,11 +7,15 @@ import Foundation
|
||||
|
||||
public final class FifoCache<Key: Hashable, Value> {
|
||||
|
||||
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<Key: Hashable, Value> {
|
||||
private var keyWriteIndex: Int
|
||||
private var storage: Dictionary<Key, Value>
|
||||
|
||||
private let queue = DispatchQueue(label: "FifoCache-\(UUID().uuidString)", qos: .userInteractive)
|
||||
private let queue: DispatchQueue
|
||||
}
|
||||
|
@ -44,5 +44,5 @@ final class ColorUtils {
|
||||
}
|
||||
}
|
||||
|
||||
private let colorCache = FifoCache<Int, NSColor>(count: 500)
|
||||
private let cgColorCache = FifoCache<Int, CGColor>(count: 500)
|
||||
private let colorCache = FifoCache<Int, NSColor>(count: 500, queueQos: .userInteractive)
|
||||
private let cgColorCache = FifoCache<Int, CGColor>(count: 500, queueQos: .userInteractive)
|
||||
|
@ -77,5 +77,8 @@ final class FontUtils {
|
||||
}
|
||||
}
|
||||
|
||||
private let fontCache = FifoCache<SizedFontTrait, NSFont>(count: 100)
|
||||
private let cellSizeWithDefaultLinespacingCache = FifoCache<NSFont, CGSize>(count: 100)
|
||||
private let fontCache = FifoCache<SizedFontTrait, NSFont>(count: 100, queueQos: .userInteractive)
|
||||
private let cellSizeWithDefaultLinespacingCache = FifoCache<NSFont, CGSize>(
|
||||
count: 100,
|
||||
queueQos: .userInteractive
|
||||
)
|
||||
|
@ -272,7 +272,10 @@ final class Typesetter {
|
||||
}
|
||||
}
|
||||
|
||||
private let ctRunsCache = FifoCache<Array<Unicode.UTF16.CodeUnit>, CtRunsAndFont>(count: 5000)
|
||||
private let ctRunsCache = FifoCache<Array<Unicode.UTF16.CodeUnit>, CtRunsAndFont>(
|
||||
count: 5000,
|
||||
queueQos: .userInteractive
|
||||
)
|
||||
|
||||
private let log = OSLog(subsystem: Defs.loggerSubsystem, category: Defs.LoggerCategory.view)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user