From a8bcc6afba70241bd50b02a992126f41f86b406e Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Fri, 13 Nov 2015 19:52:35 -0800 Subject: [PATCH] Split the work into 2 jobs per computer to retrieve assets faster --- .../ViewControllers/MainFrameViewController.m | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/Limelight/ViewControllers/MainFrameViewController.m b/Limelight/ViewControllers/MainFrameViewController.m index f741e9a..f259dde 100644 --- a/Limelight/ViewControllers/MainFrameViewController.m +++ b/Limelight/ViewControllers/MainFrameViewController.m @@ -696,13 +696,31 @@ static NSMutableSet* hostList; _sortedAppList = [host.appList allObjects]; _sortedAppList = [_sortedAppList sortedArrayUsingSelector:@selector(compareName:)]; - // Start populating the box art cache asynchronously + // Split the sorted array in half to allow 2 jobs to process app assets at once + NSArray *firstHalf; + NSArray *secondHalf; + NSRange range; + + range.location = 0; + range.length = [_sortedAppList count] / 2; + + firstHalf = [_sortedAppList subarrayWithRange:range]; + + range.location = range.length; + range.length = [_sortedAppList count] - range.length; + + secondHalf = [_sortedAppList subarrayWithRange:range]; + + // Start 2 jobs dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ - Log(LOG_I, @"Starting per-computer box art caching job"); - for (App* app in host.appList) { + for (App* app in firstHalf) { + [self updateBoxArtCacheForApp:app]; + } + }); + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ + for (App* app in secondHalf) { [self updateBoxArtCacheForApp:app]; } - Log(LOG_I, @"Per-computer box art caching job completed"); }); [hostScrollView removeFromSuperview];