Revert replacement of @synchronized in SDWebImageCombinedOperation
This commit is contained in:
parent
0b8207b1d2
commit
3ee1b60678
|
@ -347,34 +347,20 @@
|
|||
@end
|
||||
|
||||
|
||||
@interface SDWebImageCombinedOperation ()
|
||||
|
||||
@property (strong, nonatomic, nonnull) dispatch_semaphore_t cancelLock; // a lock to make the `cancel` method thread-safe
|
||||
|
||||
@end
|
||||
|
||||
@implementation SDWebImageCombinedOperation
|
||||
|
||||
- (instancetype)init {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_cancelLock = dispatch_semaphore_create(1);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)cancel {
|
||||
LOCK(self.cancelLock);
|
||||
self.cancelled = YES;
|
||||
if (self.cacheOperation) {
|
||||
[self.cacheOperation cancel];
|
||||
self.cacheOperation = nil;
|
||||
@synchronized(self) {
|
||||
self.cancelled = YES;
|
||||
if (self.cacheOperation) {
|
||||
[self.cacheOperation cancel];
|
||||
self.cacheOperation = nil;
|
||||
}
|
||||
if (self.downloadToken) {
|
||||
[self.manager.imageDownloader cancel:self.downloadToken];
|
||||
}
|
||||
[self.manager safelyRemoveOperationFromRunning:self];
|
||||
}
|
||||
if (self.downloadToken) {
|
||||
[self.manager.imageDownloader cancel:self.downloadToken];
|
||||
}
|
||||
[self.manager safelyRemoveOperationFromRunning:self];
|
||||
UNLOCK(self.cancelLock);
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in New Issue