Skip to content

Commit

Permalink
Performing cache callbacks from the ioQueue asynchronously.
Browse files Browse the repository at this point in the history
- more appropriate than dispatch_main_sync_safe, since we’ll always be on the ioQueue when calling
- prevents deadlock situation described in SDWebImage#625
  • Loading branch information
matej committed Mar 24, 2014
1 parent 4b26a89 commit dd682c9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions SDWebImage/SDImageCache.m
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ - (NSOperation *)queryDiskCacheForKey:(NSString *)key done:(void (^)(UIImage *im
[self.memCache setObject:diskImage forKey:key cost:cost];
}

dispatch_main_sync_safe(^{
dispatch_async(dispatch_get_main_queue(), ^{
doneBlock(diskImage, SDImageCacheTypeDisk);
});
}
Expand Down Expand Up @@ -349,7 +349,7 @@ - (void)clearDiskOnCompletion:(void (^)())completion
error:NULL];

if (completion) {
dispatch_main_sync_safe(^{
dispatch_async(dispatch_get_main_queue(), ^{
completion();
});
}
Expand Down Expand Up @@ -486,7 +486,7 @@ - (void)calculateSizeWithCompletionBlock:(void (^)(NSUInteger fileCount, NSUInte
}

if (completionBlock) {
dispatch_main_sync_safe(^{
dispatch_async(dispatch_get_main_queue(), ^{
completionBlock(fileCount, totalSize);
});
}
Expand Down

0 comments on commit dd682c9

Please sign in to comment.