mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-24 07:05:35 +00:00
Stricter locking assertions (#1024)
- Rename `ASDisplayNodeAssertLockUnownedByCurrentThread` to `ASAssertUnlocked`, and `ASDisplayNodeAssertLockOwnedByCurrentThread` to `ASAssertLocked` -> shorter and hopefully easier to distinguish between the two. - Add assertions to `_locked_` and `_u_` (i.e "unlocked") methods. - Turn `CHECK_LOCKING_SAFETY` flag on by default. After #1022 and #1023, we're in a good shape to actually enforce locked/unlocked requirements of internal methods. Our test suite passed, and we'll test more at Pinterest after the sync this week. - Fix ASVideoNode to avoid calling `play` while holding the lock. That method inserts a subnode and must be called lock free. - Simplify `_loaded(node)` to only nil-check `_layer` because regardless of whether the node is view or layer backed, the layer should always be set if loaded. Use it throughout. - Other minor changes.
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
#import <AsyncDisplayKit/ASAvailability.h>
|
||||
#import <AsyncDisplayKit/ASBasicImageDownloader.h>
|
||||
#import <AsyncDisplayKit/ASDisplayNodeExtras.h>
|
||||
#import <AsyncDisplayKit/ASDisplayNodeInternal.h>
|
||||
#import <AsyncDisplayKit/ASDisplayNode+FrameworkPrivate.h>
|
||||
#import <AsyncDisplayKit/ASDisplayNode+Subclasses.h>
|
||||
#import <AsyncDisplayKit/ASEqualityHelpers.h>
|
||||
@@ -149,6 +150,8 @@
|
||||
|
||||
- (void)_locked_setImage:(UIImage *)image
|
||||
{
|
||||
ASAssertLocked(__instanceLock__);
|
||||
|
||||
BOOL imageWasSetExternally = (image != nil);
|
||||
BOOL shouldCancelAndClear = imageWasSetExternally && (imageWasSetExternally != _imageWasSetExternally);
|
||||
_imageWasSetExternally = imageWasSetExternally;
|
||||
@@ -175,6 +178,7 @@
|
||||
|
||||
- (void)_locked__setImage:(UIImage *)image
|
||||
{
|
||||
ASAssertLocked(__instanceLock__);
|
||||
[super _locked_setImage:image];
|
||||
}
|
||||
|
||||
@@ -508,6 +512,8 @@
|
||||
|
||||
- (void)_locked_cancelDownloadAndClearImageWithResumePossibility:(BOOL)storeResume
|
||||
{
|
||||
ASAssertLocked(__instanceLock__);
|
||||
|
||||
[self _locked_cancelImageDownloadWithResumePossibility:storeResume];
|
||||
|
||||
[self _locked_setAnimatedImage:nil];
|
||||
@@ -532,6 +538,8 @@
|
||||
|
||||
- (void)_locked_cancelImageDownloadWithResumePossibility:(BOOL)storeResume
|
||||
{
|
||||
ASAssertLocked(__instanceLock__);
|
||||
|
||||
if (!_downloadIdentifier) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user