diff --git a/AsyncDisplayKit/ASMultiplexImageNode.mm b/AsyncDisplayKit/ASMultiplexImageNode.mm index 6d1e2a6c86..9a5fd6615d 100644 --- a/AsyncDisplayKit/ASMultiplexImageNode.mm +++ b/AsyncDisplayKit/ASMultiplexImageNode.mm @@ -346,15 +346,16 @@ typedef void(^ASMultiplexImageLoadCompletionBlock)(UIImage *image, id imageIdent - (void)setShouldRenderProgressImages:(BOOL)shouldRenderProgressImages { - ASDN::MutexLocker l(__instanceLock__); + __instanceLock__.lock(); if (shouldRenderProgressImages == _shouldRenderProgressImages) { + __instanceLock__.unlock(); return; } _shouldRenderProgressImages = shouldRenderProgressImages; - ASDN::MutexUnlocker u(__instanceLock__); + __instanceLock__.unlock(); [self _updateProgressImageBlockOnDownloaderIfNeeded]; } diff --git a/AsyncDisplayKit/ASNetworkImageNode.mm b/AsyncDisplayKit/ASNetworkImageNode.mm index 432c50b5ff..3d06a87c8c 100755 --- a/AsyncDisplayKit/ASNetworkImageNode.mm +++ b/AsyncDisplayKit/ASNetworkImageNode.mm @@ -224,15 +224,16 @@ static const CGSize kMinReleaseImageOnBackgroundSize = {20.0, 20.0}; - (void)setShouldRenderProgressImages:(BOOL)shouldRenderProgressImages { - ASDN::MutexLocker l(__instanceLock__); + __instanceLock__.lock(); if (shouldRenderProgressImages == _shouldRenderProgressImages) { + __instanceLock__.unlock(); return; } _shouldRenderProgressImages = shouldRenderProgressImages; - ASDN::MutexUnlocker u(__instanceLock__); + __instanceLock__.unlock(); [self _updateProgressImageBlockOnDownloaderIfNeeded]; } diff --git a/AsyncDisplayKit/Details/ASMainSerialQueue.mm b/AsyncDisplayKit/Details/ASMainSerialQueue.mm index ffd46fc21e..e6ed595450 100644 --- a/AsyncDisplayKit/Details/ASMainSerialQueue.mm +++ b/AsyncDisplayKit/Details/ASMainSerialQueue.mm @@ -39,8 +39,10 @@ { ASDN::MutexLocker l(_serialQueueLock); [_blocks addObject:block]; - ASDN::MutexUnlocker u(_serialQueueLock); - [self runBlocks]; + { + ASDN::MutexUnlocker u(_serialQueueLock); + [self runBlocks]; + } } - (void)runBlocks @@ -55,8 +57,10 @@ } else { break; } - ASDN::MutexUnlocker u(_serialQueueLock); - block(); + { + ASDN::MutexUnlocker u(_serialQueueLock); + block(); + } } while (true); };