Remove the previous using atomic property, use lock instead.

This commit is contained in:
DreamPiggy 2019-03-31 15:53:33 +08:00
parent f9e80d18eb
commit f060310ffe
2 changed files with 16 additions and 6 deletions

View File

@ -58,7 +58,7 @@ typedef NS_ENUM(NSUInteger, SDImageCachesManagerOperationPolicy) {
/**
All caches in caches manager. The caches array is a priority queue, which means the later added cache will have the highest priority
*/
@property (atomic, copy, readwrite, nullable) NSArray<id<SDImageCache>> *caches;
@property (nonatomic, copy, readwrite, nullable) NSArray<id<SDImageCache>> *caches;
/**
Add a new cache to the end of caches array. Which has the highest priority.

View File

@ -75,7 +75,9 @@
if (!key) {
return nil;
}
NSArray<id<SDImageCache>> *caches = [self.caches copy];
SD_LOCK(self.cachesLock);
NSArray<id<SDImageCache>> *caches = self.caches;
SD_UNLOCK(self.cachesLock);
NSUInteger count = caches.count;
if (count == 0) {
return nil;
@ -117,7 +119,9 @@
if (!key) {
return;
}
NSArray<id<SDImageCache>> *caches = [self.caches copy];
SD_LOCK(self.cachesLock);
NSArray<id<SDImageCache>> *caches = self.caches;
SD_UNLOCK(self.cachesLock);
NSUInteger count = caches.count;
if (count == 0) {
return;
@ -155,7 +159,9 @@
if (!key) {
return;
}
NSArray<id<SDImageCache>> *caches = [self.caches copy];
SD_LOCK(self.cachesLock);
NSArray<id<SDImageCache>> *caches = self.caches;
SD_UNLOCK(self.cachesLock);
NSUInteger count = caches.count;
if (count == 0) {
return;
@ -193,7 +199,9 @@
if (!key) {
return;
}
NSArray<id<SDImageCache>> *caches = [self.caches copy];
SD_LOCK(self.cachesLock);
NSArray<id<SDImageCache>> *caches = self.caches;
SD_UNLOCK(self.cachesLock);
NSUInteger count = caches.count;
if (count == 0) {
return;
@ -230,7 +238,9 @@
}
- (void)clearWithCacheType:(SDImageCacheType)cacheType completion:(SDWebImageNoParamsBlock)completionBlock {
NSArray<id<SDImageCache>> *caches = [self.caches copy];
SD_LOCK(self.cachesLock);
NSArray<id<SDImageCache>> *caches = self.caches;
SD_UNLOCK(self.cachesLock);
NSUInteger count = caches.count;
if (count == 0) {
return;