SDWebImageDownloaderQueueMode type renamed. Fixed typo. Added description for renamed type. Type renamed because "queue" notion is a FIFO only, but LIFO is a stack, and if we give the type a neutral name, we can avoid logical inconsistencies.

This commit is contained in:
Andrew Vyazovoy 2013-03-27 23:43:42 +07:00
parent 6284e4070d
commit ee9af6406c
3 changed files with 15 additions and 9 deletions

View File

@ -333,7 +333,7 @@
nil];
}
[SDWebImageManager.sharedManager.imageDownloader setValue:@"SDWebImage Demo" forHTTPHeaderField:@"AppName"];
SDWebImageManager.sharedManager.imageDownloader.queueMode = SDWebImageDownloaderLIFOQueueMode;
SDWebImageManager.sharedManager.imageDownloader.executionOrder = SDWebImageDownloaderLIFOExecutionOrder;
return self;
}

View File

@ -28,9 +28,15 @@ typedef enum
typedef enum
{
SDWebImageDownloaderFILOQueueMode,
SDWebImageDownloaderLIFOQueueMode
} SDWebImageDownloaderQueueMode;
SDWebImageDownloaderFIFOExecutionOrder,
/**
* Default value. All download operations will execute in queue style (first-in-first-out).
*/
SDWebImageDownloaderLIFOExecutionOrder
/**
* All download operations will execute in stack style (last-in-first-out).
*/
} SDWebImageDownloaderExecutionOrder;
extern NSString *const SDWebImageDownloadStartNotification;
extern NSString *const SDWebImageDownloadStopNotification;
@ -46,9 +52,9 @@ typedef void(^SDWebImageDownloaderCompletedBlock)(UIImage *image, NSData *data,
@property (assign, nonatomic) NSInteger maxConcurrentDownloads;
/**
* Changes download operations unqueue mode. Default value is `SDWebImageDownloaderFILOQueueMode`.
* Changes download operations execution order. Default value is `SDWebImageDownloaderFIFOExecutionOrder`.
*/
@property (assign, nonatomic) SDWebImageDownloaderQueueMode queueMode;
@property (assign, nonatomic) SDWebImageDownloaderExecutionOrder executionOrder;
+ (SDWebImageDownloader *)sharedDownloader;

View File

@ -67,7 +67,7 @@ static NSString *const kCompletedCallbackKey = @"completed";
{
if ((self = [super init]))
{
_queueMode = SDWebImageDownloaderFILOQueueMode;
_executionOrder = SDWebImageDownloaderFIFOExecutionOrder;
_downloadQueue = NSOperationQueue.new;
_downloadQueue.maxConcurrentOperationCount = 2;
_URLCallbacks = NSMutableDictionary.new;
@ -158,9 +158,9 @@ static NSString *const kCompletedCallbackKey = @"completed";
[sself removeCallbacksForURL:url];
}];
[wself.downloadQueue addOperation:operation];
if (wself.queueMode == SDWebImageDownloaderLIFOQueueMode)
if (wself.executionOrder == SDWebImageDownloaderLIFOExecutionOrder)
{
// Emulate LIFO queue mode by systematically adding new operations as last operation's dependency
// Emulate LIFO execution order by systematically adding new operations as last operation's dependency
[wself.lastAddedOperation addDependency:operation];
wself.lastAddedOperation = operation;
}