summaryrefslogtreecommitdiff
path: root/macosx/main.mm
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2014-03-01 13:05:13 +0100
committerKonstantin Käfer <mail@kkaefer.com>2014-03-01 13:05:13 +0100
commit6c58101b12ee8e599aff3541f10c1fbfe5a027fb (patch)
tree190fd66b912ab47956fd547237056a9ee1ecdbbe /macosx/main.mm
parent0782cfc5be92ebc79711f6f9756db303026030e3 (diff)
downloadqtlocation-mapboxgl-6c58101b12ee8e599aff3541f10c1fbfe5a027fb.tar.gz
multithreaded curl for linux
Diffstat (limited to 'macosx/main.mm')
-rw-r--r--macosx/main.mm17
1 files changed, 11 insertions, 6 deletions
diff --git a/macosx/main.mm b/macosx/main.mm
index 973db9a861..bed18013cb 100644
--- a/macosx/main.mm
+++ b/macosx/main.mm
@@ -240,7 +240,12 @@ void restart() {
[[NSApplication sharedApplication] postEvent: [NSEvent eventWithCGEvent:event] atStart:NO];
}
-Request request_http(std::string url, std::function<void(Response&)> background_function, std::function<void()> foreground_callback)
+struct Request {
+ int16_t identifier;
+ std::string original_url;
+};
+
+Request *request_http(std::string url, std::function<void(Response&)> background_function, std::function<void()> foreground_callback)
{
NSURLSessionDataTask *task = [[NSURLSession sharedSession] dataTaskWithURL:[NSURL URLWithString:@(url.c_str())] completionHandler:^(NSData *data, NSURLResponse *response, NSError *error)
{
@@ -262,20 +267,20 @@ Request request_http(std::string url, std::function<void(Response&)> background_
[task resume];
- Request req;
+ Request *req = new Request();
- req.identifier = task.taskIdentifier;
- req.original_url = url;
+ req->identifier = task.taskIdentifier;
+ req->original_url = url;
return req;
}
-void cancel_request_http(Request request)
+void cancel_request_http(Request *request)
{
[[NSURLSession sharedSession] getTasksWithCompletionHandler:^(NSArray *dataTasks, NSArray *uploadTasks, NSArray *downloadTasks)
{
for (NSURLSessionDownloadTask *task in downloadTasks)
- if (task.taskIdentifier == request.identifier)
+ if (task.taskIdentifier == request->identifier)
return [task cancel];
}];
}