use higher priority queue for image loading
This commit is contained in:
@@ -267,12 +267,14 @@ final class ViewController: UIViewController, UIGestureRecognizerDelegate {
|
||||
}
|
||||
|
||||
func saveGlobalState() {
|
||||
do {
|
||||
try JSONEncoder().encode(globalState).write(
|
||||
to: documentsURL.appendingPathComponent("state.json")
|
||||
)
|
||||
} catch {
|
||||
print("failed to save global state")
|
||||
queue.async {
|
||||
do {
|
||||
try JSONEncoder().encode(self.globalState).write(
|
||||
to: self.documentsURL.appendingPathComponent("state.json")
|
||||
)
|
||||
} catch {
|
||||
print("failed to save global state")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1785,7 +1787,8 @@ class ImageLoader {
|
||||
let token = CancellationToken()
|
||||
activeTokens[key] = token
|
||||
|
||||
queue.async { [weak self] in
|
||||
// This should be fine even for preloading because of how heavy work is cached and useless work cancelled.
|
||||
queue.async(qos: .userInitiated) { [weak self] in
|
||||
guard let self = self else { return }
|
||||
|
||||
func finish() {
|
||||
@@ -1795,6 +1798,7 @@ class ImageLoader {
|
||||
self.loadingTasks.removeValue(forKey: key)
|
||||
}
|
||||
}
|
||||
|
||||
func setImage(_ image: UIImage) {
|
||||
DispatchQueue.main.async {
|
||||
if let callback = self.loadingTasks[key] {
|
||||
@@ -1803,8 +1807,6 @@ class ImageLoader {
|
||||
}
|
||||
}
|
||||
|
||||
if token.isCancelled { finish(); return }
|
||||
|
||||
func extractData() -> Data? {
|
||||
var extractedData = Data()
|
||||
if self.archives.object(forKey: archiveURL.lastPathComponent as NSString) == nil {
|
||||
|
||||
Reference in New Issue
Block a user