Revert "Synchronise getter and setter of the cancelled property of the SDWebImageCombinedOperation in order to eliminate data race."
This reverts commit 5a18c84529
.
This commit is contained in:
parent
122c3d7ca5
commit
ad592765cb
|
@ -17,9 +17,7 @@
|
||||||
static id<SDImageCache> _defaultImageCache;
|
static id<SDImageCache> _defaultImageCache;
|
||||||
static id<SDImageLoader> _defaultImageLoader;
|
static id<SDImageLoader> _defaultImageLoader;
|
||||||
|
|
||||||
@interface SDWebImageCombinedOperation () {
|
@interface SDWebImageCombinedOperation ()
|
||||||
SD_LOCK_DECLARE(_cancelledLock); // a lock to keep the access to `cancelled` thread-safe
|
|
||||||
}
|
|
||||||
|
|
||||||
@property (assign, nonatomic, getter = isCancelled) BOOL cancelled;
|
@property (assign, nonatomic, getter = isCancelled) BOOL cancelled;
|
||||||
@property (strong, nonatomic, readwrite, nullable) id<SDWebImageOperation> loaderOperation;
|
@property (strong, nonatomic, readwrite, nullable) id<SDWebImageOperation> loaderOperation;
|
||||||
|
@ -805,29 +803,12 @@ static id<SDImageLoader> _defaultImageLoader;
|
||||||
|
|
||||||
@implementation SDWebImageCombinedOperation
|
@implementation SDWebImageCombinedOperation
|
||||||
|
|
||||||
- (instancetype)init {
|
|
||||||
if (self = [super init]) {
|
|
||||||
SD_LOCK_INIT(_cancelledLock);
|
|
||||||
}
|
|
||||||
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (BOOL)isCancelled {
|
|
||||||
BOOL isCancelled = NO;
|
|
||||||
SD_LOCK(_cancelledLock);
|
|
||||||
isCancelled = _cancelled;
|
|
||||||
SD_UNLOCK(_cancelledLock);
|
|
||||||
return isCancelled;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)cancel {
|
- (void)cancel {
|
||||||
SD_LOCK(_cancelledLock);
|
@synchronized(self) {
|
||||||
if (_cancelled) {
|
if (self.isCancelled) {
|
||||||
SD_UNLOCK(_cancelledLock);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_cancelled = YES;
|
self.cancelled = YES;
|
||||||
if (self.cacheOperation) {
|
if (self.cacheOperation) {
|
||||||
[self.cacheOperation cancel];
|
[self.cacheOperation cancel];
|
||||||
self.cacheOperation = nil;
|
self.cacheOperation = nil;
|
||||||
|
@ -837,7 +818,7 @@ static id<SDImageLoader> _defaultImageLoader;
|
||||||
self.loaderOperation = nil;
|
self.loaderOperation = nil;
|
||||||
}
|
}
|
||||||
[self.manager safelyRemoveOperationFromRunning:self];
|
[self.manager safelyRemoveOperationFromRunning:self];
|
||||||
SD_UNLOCK(_cancelledLock);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
Loading…
Reference in New Issue