mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-24 07:05:35 +00:00
I wrote a bunch of code with the Mutex::Unlocker and didn't understand it. (#2150)
This commit is contained in:
committed by
Adlai Holler
parent
905508e9be
commit
e6e5c346de
@@ -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];
|
||||
}
|
||||
|
||||
|
||||
@@ -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];
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user