Fix the issue that prefetcher will cause stack overflow is the input urls list is huge because of recursion function call

This commit is contained in:
DreamPiggy 2018-01-28 19:06:46 +08:00
parent 2052557e83
commit 7e96b776ca
1 changed files with 2 additions and 1 deletions

View File

@ -80,7 +80,8 @@
]; ];
} }
if (self.prefetchURLs.count > self.requestedCount) { if (self.prefetchURLs.count > self.requestedCount) {
dispatch_queue_async_safe(self.prefetcherQueue, ^{ dispatch_async(self.prefetcherQueue, ^{
// we need dispatch to avoid function recursion call. This can prevent stack overflow even for huge urls list
[self startPrefetchingAtIndex:self.requestedCount]; [self startPrefetchingAtIndex:self.requestedCount];
}); });
} else if (self.finishedCount == self.requestedCount) { } else if (self.finishedCount == self.requestedCount) {