In this example I kick off 100 NSURLSessionDataTask
at default priority but then set the last one to high priority. However it seems to have no effect at all as the last task still ends up running last.
NSURLSession *session = ...
NSURLRequest *request = ...
for (int i = 1; i<=100; i++) {
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
NSLog(@"%d", i);
}];
if (i == 100) {
dataTask.priority = NSURLSessionTaskPriorityHigh;
}
[dataTask resume];
}
Why doesn't this task with high priority run before the other 99 at default priority? I would expect maybe a few of the earlier tasks might start to execute before the high priority task was even added, but not all of them.
I have even tried with HTTPMaximumConnectionsPerHost set to 1, makes no difference.