[ASNetworkImageNode] Carry recent progress image block changes over from multiplex image node

This commit is contained in:
Adlai Holler 2016-04-22 12:34:13 -05:00
parent f5adc7999b
commit bc8a2b19ef
2 changed files with 15 additions and 3 deletions

View File

@ -452,9 +452,13 @@ typedef void(^ASMultiplexImageLoadCompletionBlock)(UIImage *image, id imageIdent
#pragma mark -
/**
@note: This should be called without _downloadIdentifierLock held. We will lock
super to read our interface state and it's best to avoid acquiring both locks.
*/
- (void)_updateProgressImageBlockOnDownloaderIfNeeded
{
// Read our interface state so that we don't lock super while holding our lock.
// Read our interface state before locking so that we don't lock super while holding our lock.
ASInterfaceState interfaceState = self.interfaceState;
ASDN::MutexLocker l(_downloadIdentifierLock);

View File

@ -213,8 +213,8 @@ static const CGSize kMinReleaseImageOnBackgroundSize = {20.0, 20.0};
{
[super visibilityDidChange:isVisible];
ASDN::MutexLocker l(_lock);
if (_downloaderImplementsSetPriority) {
ASDN::MutexLocker l(_lock);
if (_downloadIdentifier != nil) {
if (isVisible) {
[_downloader setPriority:ASImageDownloaderPriorityVisible withDownloadIdentifier:_downloadIdentifier];
@ -254,14 +254,22 @@ static const CGSize kMinReleaseImageOnBackgroundSize = {20.0, 20.0};
#pragma mark - Private methods -- only call with lock.
/**
@note: This should be called without _lock held. We will lock
super to read our interface state and it's best to avoid acquiring both locks.
*/
- (void)_updateProgressImageBlockOnDownloaderIfNeeded
{
// Read our interface state before locking so that we don't lock super while holding our lock.
ASInterfaceState interfaceState = self.interfaceState;
ASDN::MutexLocker l(_lock);
if (!_downloaderImplementsSetProgress || _downloadIdentifier == nil) {
return;
}
ASImageDownloaderProgressImage progress = nil;
if (ASInterfaceStateIncludesVisible(self.interfaceState)) {
if (ASInterfaceStateIncludesVisible(interfaceState)) {
__weak __typeof__(self) weakSelf = self;
progress = ^(UIImage * _Nonnull progressImage, id _Nullable downloadIdentifier) {
__typeof__(self) strongSelf = weakSelf;