Authored by Lizhen Hu

Revert replacement of @synchronized in SDWebImageCombinedOperation

@@ -347,34 +347,20 @@ @@ -347,34 +347,20 @@
347 @end 347 @end
348 348
349 349
350 -@interface SDWebImageCombinedOperation ()  
351 -  
352 -@property (strong, nonatomic, nonnull) dispatch_semaphore_t cancelLock; // a lock to make the `cancel` method thread-safe  
353 -  
354 -@end  
355 -  
356 @implementation SDWebImageCombinedOperation 350 @implementation SDWebImageCombinedOperation
357 351
358 -- (instancetype)init {  
359 - self = [super init];  
360 - if (self) {  
361 - _cancelLock = dispatch_semaphore_create(1);  
362 - }  
363 - return self;  
364 -}  
365 -  
366 - (void)cancel { 352 - (void)cancel {
367 - LOCK(self.cancelLock);  
368 - self.cancelled = YES;  
369 - if (self.cacheOperation) {  
370 - [self.cacheOperation cancel];  
371 - self.cacheOperation = nil;  
372 - }  
373 - if (self.downloadToken) {  
374 - [self.manager.imageDownloader cancel:self.downloadToken]; 353 + @synchronized(self) {
  354 + self.cancelled = YES;
  355 + if (self.cacheOperation) {
  356 + [self.cacheOperation cancel];
  357 + self.cacheOperation = nil;
  358 + }
  359 + if (self.downloadToken) {
  360 + [self.manager.imageDownloader cancel:self.downloadToken];
  361 + }
  362 + [self.manager safelyRemoveOperationFromRunning:self];
375 } 363 }
376 - [self.manager safelyRemoveOperationFromRunning:self];  
377 - UNLOCK(self.cancelLock);  
378 } 364 }
379 365
380 @end 366 @end