fixed possible lockups on app start
This commit is contained in:
1 parent
43dfc52bc7
commit
3734d7ff2c
7 files changed
+452
-173
No files matched your search
@@ -0,0 +1,11 @@
|
||||
/// Delay before retry number [attempt] (1-based): [base] doubled per attempt,
|
||||
/// capped at [max].
|
||||
Duration exponentialBackoff(
|
||||
int attempt, {
|
||||
Duration base = const Duration(milliseconds: 500),
|
||||
Duration max = const Duration(seconds: 5),
|
||||
}) {
|
||||
final exponent = (attempt - 1).clamp(0, 30);
|
||||
final millis = base.inMilliseconds * (1 << exponent);
|
||||
return millis >= max.inMilliseconds ? max : Duration(milliseconds: millis);
|
||||
}
|
||||
Reference in new issue
Block a user