Merge pull request #205 from facebook/image-load-blocking

Dispatch lazy image downloaders to another thread
This commit is contained in:
Nadine Salter 2015-01-07 16:36:19 -08:00
commit 42f801f269

View File

@ -234,11 +234,17 @@
} }
}; };
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[_cache fetchCachedImageWithURL:_URL [_cache fetchCachedImageWithURL:_URL
callbackQueue:dispatch_get_main_queue() callbackQueue:dispatch_get_main_queue()
completion:cacheCompletion]; completion:cacheCompletion];
});
} else { } else {
// NSURLSessionDownloadTask will do file I/O to create a temp directory. If called on the main thread this
// will cause significant performance issues.
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[self _downloadImageWithCompletion:finished]; [self _downloadImageWithCompletion:finished];
});
} }
} }
} }