From 01e9e94ba65150e4a0fa36329f661af831ffdf35 Mon Sep 17 00:00:00 2001 From: Hans Larsen Date: Tue, 18 May 2021 15:49:41 -0700 Subject: [PATCH] fix: exponential backoff which was jumping to waiting for cap --- Cargo.toml | 2 +- src/throttle.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 142a9b8..5b05c54 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "garcon" -version = "0.2.2" +version = "0.2.3" authors = ["Hans Larsen "] edition = "2018" description = "A collection of trait and classes to make your thread or async function wait." diff --git a/src/throttle.rs b/src/throttle.rs index 10af9e1..c6fa5df 100644 --- a/src/throttle.rs +++ b/src/throttle.rs @@ -132,7 +132,7 @@ impl ExponentialBackoffWaiter { let current = next.load(Ordering::Relaxed); // Find the next throttle. - let next = u64::max( + let next = u64::min( (current as f64 * self.multiplier) as u64, self.cap_as_micros, );