fix: limit schedule timer tolerance to 10 min
This commit is contained in:
@@ -113,10 +113,14 @@ static _Atomic(NSUInteger) _queueSize = 0;
|
|||||||
});
|
});
|
||||||
if (!nextTime)
|
if (!nextTime)
|
||||||
nextTime = [NSDate distantFuture];
|
nextTime = [NSDate distantFuture];
|
||||||
NSTimeInterval tolerance = [nextTime timeIntervalSinceNow] * 0.15;
|
int tolerance = (int)([nextTime timeIntervalSinceNow] * 0.15);
|
||||||
_timer.tolerance = (tolerance < 1 ? 1 : tolerance); // at least 1 sec
|
tolerance = (tolerance < 1 ? 1 : tolerance > 600 ? 600 : tolerance); // at least 1 sec, upto 10 min
|
||||||
|
_timer.tolerance = tolerance;
|
||||||
_timer.fireDate = nextTime;
|
_timer.fireDate = nextTime;
|
||||||
PostNotification(kNotificationScheduleTimerChanged, nil);
|
PostNotification(kNotificationScheduleTimerChanged, nil);
|
||||||
|
#ifdef DEBUG
|
||||||
|
NSLog(@"schedule timer: %@ (+/- %d sec)", nextTime, tolerance);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Called when schedule timer runs out (earliest @c .schedule date). Or if forced by user.
|
/// Called when schedule timer runs out (earliest @c .schedule date). Or if forced by user.
|
||||||
|
|||||||
Reference in New Issue
Block a user