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:
Li Tan
2015-02-09 16:39:16 -08:00
parent e08975cbfa
commit 2f88ce56a2
6 changed files with 152 additions and 2 deletions

View File

@@ -112,6 +112,8 @@ static BOOL _isInterceptedSelector(SEL sel)
ASRangeController *_rangeController;
}
@property (atomic, assign) BOOL asyncDataSouceLocked;
@end
@implementation ASTableView
@@ -137,6 +139,8 @@ static BOOL _isInterceptedSelector(SEL sel)
_proxyDelegate = [[_ASTableViewProxy alloc] initWithTarget:nil interceptor:self];
super.delegate = (id<UITableViewDelegate>)_proxyDelegate;
_asyncDataSouceLocked = NO;
return self;
}
@@ -425,6 +429,28 @@ static BOOL _isInterceptedSelector(SEL sel)
return CGSizeMake(self.bounds.size.width, FLT_MAX);
}
- (void)dataControllerLockDataSourceForDataUpdating
{
ASDisplayNodeAssert(!self.asyncDataSouceLocked, @"The data source has already been locked !");
self.asyncDataSouceLocked = YES;
if ([_asyncDataSource respondsToSelector:@selector(tableViewLockDataSourceForDataUpdating:)]) {
[_asyncDataSource tableViewLockDataSourceForDataUpdating:self];
}
}
- (void)dataControllerUnlockDataSourceForDataUpdating
{
ASDisplayNodeAssert(self.asyncDataSouceLocked, @"The data source has already been unlocked !");
self.asyncDataSouceLocked = NO;
if ([_asyncDataSource respondsToSelector:@selector(tableViewUnlockDataSourceForDataUpdating:)]) {
[_asyncDataSource tableViewUnlockDataSourceForDataUpdating:self];
}
}
- (NSUInteger)dataController:(ASDataController *)dataControllre rowsInSection:(NSUInteger)section
{
return [_asyncDataSource tableView:self numberOfRowsInSection:section];