improve waiting times

sync2
Laurent 8 months ago
parent 760a3135ad
commit 633d50a616
  1. 12
      LeStorage/ApiCallCollection.swift

@ -226,12 +226,12 @@ actor ApiCallCollection<T: SyncedStorable>: SomeCallCollection {
/// Wait for an exponentionnaly long time depending on the number of attemps /// Wait for an exponentionnaly long time depending on the number of attemps
fileprivate func _wait() async { fileprivate func _wait() async {
#if DEBUG var seconds = self._attemptLoops
let seconds = self._attemptLoops if self._attemptLoops > 5 {
#else let delay = pow(2, self._attemptLoops - 2) // starts at 16s
let delay = pow(2, self._attemptLoops) seconds = NSDecimalNumber(decimal: delay).intValue
let seconds = NSDecimalNumber(decimal: delay).intValue }
#endif
Logger.log("\(T.resourceName()): wait for \(seconds) sec") Logger.log("\(T.resourceName()): wait for \(seconds) sec")
do { do {
try await Task.sleep(until: .now + .seconds(seconds)) try await Task.sleep(until: .now + .seconds(seconds))

Loading…
Cancel
Save