mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 14:20:20 +00:00
Move ASTableView & ASCollectionView data fetching to background thread
Conflicts: AsyncDisplayKit/ASCollectionView.mm AsyncDisplayKit/Details/ASDataController.mm Conflicts: AsyncDisplayKit/ASCollectionView.mm AsyncDisplayKit/Details/ASDataController.mm
This commit is contained in:
@@ -103,6 +103,8 @@ static BOOL _isInterceptedSelector(SEL sel)
|
||||
NSMutableArray *_batchUpdateBlocks;
|
||||
}
|
||||
|
||||
@property (atomic, assign) BOOL asyncDataSourceLocked;
|
||||
|
||||
@end
|
||||
|
||||
@implementation ASCollectionView
|
||||
@@ -131,6 +133,8 @@ static BOOL _isInterceptedSelector(SEL sel)
|
||||
_proxyDelegate = [[_ASCollectionViewProxy alloc] initWithTarget:nil interceptor:self];
|
||||
super.delegate = (id<UICollectionViewDelegate>)_proxyDelegate;
|
||||
|
||||
_asyncDataSourceLocked = NO;
|
||||
|
||||
_performingBatchUpdates = NO;
|
||||
_batchUpdateBlocks = [NSMutableArray array];
|
||||
|
||||
@@ -375,6 +379,26 @@ static BOOL _isInterceptedSelector(SEL sel)
|
||||
}
|
||||
}
|
||||
|
||||
- (void)dataControllerLockDataSourceForDataUpdating
|
||||
{
|
||||
ASDisplayNodeAssert(!self.asyncDataSourceLocked, @"The data source has already been locked");
|
||||
|
||||
self.asyncDataSourceLocked = YES;
|
||||
if ([_asyncDataSource respondsToSelector:@selector(collectionViewLockDataSourceForDataUpdating:)]) {
|
||||
[_asyncDataSource collectionViewLockDataSourceForDataUpdating:self];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)dataControllerUnlockDataSourceForDataUpdating
|
||||
{
|
||||
ASDisplayNodeAssert(!self.asyncDataSourceLocked, @"The data source has alredy been unlocked !");
|
||||
|
||||
self.asyncDataSourceLocked = NO;
|
||||
if ([_asyncDataSource respondsToSelector:@selector(collectionViewUnlockDataSourceForDataUpdating:)]) {
|
||||
[_asyncDataSource collectionViewUnlockDataSourceForDataUpdating:self];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark ASRangeControllerDelegate.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user