fixed possible lockups on app start
This commit is contained in:
@@ -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