Fixed background aware timer

This commit is contained in:
Peter
2018-10-19 20:29:41 +03:00
parent f1b83b8069
commit 4e14104f3c

View File

@@ -57,7 +57,7 @@ public func suspendAwareDelay<T, E>(_ timeout: Double, granularity: Double = 4.0
var invalidateImpl: (() -> Void)?
let timer = Timer(timeout: granularity, repeat: true, completion: {
let currentTimestamp = CFAbsoluteTimeGetCurrent()
if beginTimestamp + timeout >= currentTimestamp - granularity * 1.1 {
if beginTimestamp + timeout - granularity * 1.1 <= currentTimestamp {
invalidateImpl?()
startFinalTimer()
}