Skip to content

Commit 8b315a3

Browse files
author
jason
committed
add support for high priority download
1 parent 4e4ecd6 commit 8b315a3

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

SDWebImage/SDWebImageDownloader.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,12 @@ typedef NS_OPTIONS(NSUInteger, SDWebImageDownloaderOptions) {
3737
* Enable to allow untrusted SSL ceriticates.
3838
* Useful for testing purposes. Use with caution in production.
3939
*/
40-
SDWebImageDownloaderAllowInvalidSSLCertificates = 1 << 6
40+
SDWebImageDownloaderAllowInvalidSSLCertificates = 1 << 6,
41+
/**
42+
*
43+
*/
44+
SDWebImageDownloaderHighPriority = 1 << 7,
45+
4146

4247
};
4348

SDWebImage/SDWebImageDownloader.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,10 @@ - (NSInteger)maxConcurrentDownloads {
152152
SDWebImageDownloader *sself = wself;
153153
[sself removeCallbacksForURL:url];
154154
}];
155+
156+
if (options & SDWebImageDownloaderHighPriority) {
157+
operation.queuePriority = NSOperationQueuePriorityHigh;
158+
}
155159

156160
[wself.downloadQueue addOperation:operation];
157161
if (wself.executionOrder == SDWebImageDownloaderLIFOExecutionOrder) {

SDWebImage/SDWebImageManager.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,13 @@ typedef NS_OPTIONS(NSUInteger, SDWebImageOptions) {
5555
* Enable to allow untrusted SSL ceriticates.
5656
* Useful for testing purposes. Use with caution in production.
5757
*/
58-
SDWebImageAllowInvalidSSLCertificates = 1 << 7
58+
SDWebImageAllowInvalidSSLCertificates = 1 << 7,
59+
/**
60+
* By default, image are loaded in the order they were queued. This flag move them to
61+
* the front of the queue and is loaded immediately instead of waiting for the current queue to be loaded (which
62+
* could take a while).
63+
*/
64+
SDWebImageHighPriority = 1 << 8
5965
};
6066

6167
typedef void(^SDWebImageCompletedBlock)(UIImage *image, NSError *error, SDImageCacheType cacheType);

SDWebImage/SDWebImageManager.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ - (BOOL)diskImageExistsForURL:(NSURL *)url {
127127
if (options & SDWebImageContinueInBackground) downloaderOptions |= SDWebImageDownloaderContinueInBackground;
128128
if (options & SDWebImageHandleCookies) downloaderOptions |= SDWebImageDownloaderHandleCookies;
129129
if (options & SDWebImageAllowInvalidSSLCertificates) downloaderOptions |= SDWebImageDownloaderAllowInvalidSSLCertificates;
130+
if (options & SDWebImageHighPriority) downloaderOptions |= SDWebImageDownloaderHighPriority;
130131
if (image && options & SDWebImageRefreshCached) {
131132
// force progressive off if image already cached but forced refreshing
132133
downloaderOptions &= ~SDWebImageDownloaderProgressiveDownload;

0 commit comments

Comments
 (0)