From ea3979b19e08d5893347e648bbdc28bbb9bfe010 Mon Sep 17 00:00:00 2001 From: Brad Leege Date: Fri, 8 May 2015 10:13:05 -0500 Subject: [PATCH] #1474 - Refactoring timer to be started when first event is added to queue. Debug logic and content also included --- platform/ios/MGLMapboxEvents.m | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/platform/ios/MGLMapboxEvents.m b/platform/ios/MGLMapboxEvents.m index 4450fa87f..b5a219546 100644 --- a/platform/ios/MGLMapboxEvents.m +++ b/platform/ios/MGLMapboxEvents.m @@ -163,7 +163,7 @@ NSString *const MGLEventGestureRotateStart = @"Rotation"; // Events Control _eventQueue = [[NSMutableArray alloc] init]; _flushAt = 20; - _flushAfter = 60; + _flushAfter = 15; _token = nil; _instanceID = [[NSUUID UUID] UUIDString]; @@ -382,16 +382,20 @@ NSString *const MGLEventGestureRotateStart = @"Rotation"; // Has Flush Limit Been Reached? if (_eventQueue.count >= strongSelf.flushAt) { [strongSelf flush]; + } else if (_eventQueue.count == 1) { + // If this is first new event on queue start timer, + NSLog(@"event queue is 1, start timer."); + [strongSelf startTimer]; + } else { + NSLog(@"event queue is != 1, don't adjust timer."); } - - // Reset Timer (Initial Starting of Timer after first event is pushed) - [strongSelf startTimer]; }); } // Can be called from any thread. // + (void) flush { + NSLog(@"+flush called (likely timer)"); [[MGLMapboxEvents sharedManager] flush]; }