summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad Leege <bleege@gmail.com>2015-03-25 21:07:08 -0500
committerBrad Leege <bleege@gmail.com>2015-03-25 21:07:08 -0500
commitb06e8c8dfcdd6d75f07949e1256b4a2f8e6f552e (patch)
tree0736377b73fc129df48722902cca0f562512eb33
parent53090afecbeedfd8838b0fc39a8d0f33d6235eb4 (diff)
downloadqtlocation-mapboxgl-b06e8c8dfcdd6d75f07949e1256b4a2f8e6f552e.tar.gz
#1109 - Wrapping event flush method in sync background thread.
-rw-r--r--platform/ios/MGLMapboxEvents.m30
1 files changed, 16 insertions, 14 deletions
diff --git a/platform/ios/MGLMapboxEvents.m b/platform/ios/MGLMapboxEvents.m
index 789ac4d108..838fd11d36 100644
--- a/platform/ios/MGLMapboxEvents.m
+++ b/platform/ios/MGLMapboxEvents.m
@@ -180,24 +180,26 @@ NSNumber *scale;
return;
}
- int upper = (int)_flushAt;
- if (_flushAt > [_queue count]) {
- if ([_queue count] == 0) {
- return;
- }
- upper = (int)[_queue count];
- }
+ dispatch_sync(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
- // Create Array of Events to push to the Server
- NSRange theRange = NSMakeRange(0, upper);
- NSArray *events = [_queue subarrayWithRange:theRange];
+ int upper = (int)_flushAt;
+ if (_flushAt > [_queue count]) {
+ if ([_queue count] == 0) {
+ return;
+ }
+ upper = (int)[_queue count];
+ }
- // Update Queue to remove events sent to server
- [_queue removeObjectsInRange:theRange];
+ // Create Array of Events to push to the Server
+ NSRange theRange = NSMakeRange(0, upper);
+ NSArray *events = [_queue subarrayWithRange:theRange];
- // Send Array of Events to Server
- [self postEvents:events];
+ // Update Queue to remove events sent to server
+ [_queue removeObjectsInRange:theRange];
+ // Send Array of Events to Server
+ [self postEvents:events];
+ });
}
- (void) postEvents:(NSArray *)events {