Prioritize SDWebImageDownloaderHighPriority if operation already exists

This commit is contained in:
zhongwuzw 2019-01-07 16:24:41 +08:00
parent c95be0994e
commit 8a743950e2
1 changed files with 9 additions and 0 deletions

View File

@ -307,6 +307,15 @@
// `addOperation:` does not synchronously execute the `operation.completionBlock` so this will not cause deadlock.
[self.downloadQueue addOperation:operation];
}
else if (!operation.isExecuting) {
if (options & SDWebImageDownloaderHighPriority) {
operation.queuePriority = NSOperationQueuePriorityHigh;
} else if (options & SDWebImageDownloaderLowPriority) {
operation.queuePriority = NSOperationQueuePriorityLow;
} else {
operation.queuePriority = NSOperationQueuePriorityNormal;
}
}
UNLOCK(self.operationsLock);
id downloadOperationCancelToken = [operation addHandlersForProgress:progressBlock completed:completedBlock];