1
1
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:
Tae Won Ha 2020-09-18 11:02:25 +02:00
parent 4e60d5878b
commit 9080ad8b5c
No known key found for this signature in database
GPG Key ID: E40743465B5B8B44
4 changed files with 17 additions and 7 deletions

View File

@ -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
}

View File

@ -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)

View File

@ -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
)

View File

@ -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)