Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions src/client/legacy/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,14 @@ impl<T: Poolable, K: Key> PoolInner<T, K> {
} else {
return;
};

// While someone might want a shorter duration, and it will be respected
// at checkout time, there's no need to wake up and proactively evict
// faster than this.
const MIN_CHECK: Duration = Duration::from_millis(90);

let dur = dur.max(MIN_CHECK);

let (tx, rx) = oneshot::channel();
self.idle_interval_ref = Some(tx);

Expand Down Expand Up @@ -991,8 +999,15 @@ mod tests {

// Let the timer tick passed the expiration...
tokio::time::sleep(Duration::from_millis(30)).await;
// Yield so the Interval can reap...
tokio::task::yield_now().await;

// But minimum interval is higher, so nothing should have been reaped
assert_eq!(
pool.locked().idle.get(&key).map(|entries| entries.len()),
Some(3)
);

// Now wait passed the minimum interval more
tokio::time::sleep(Duration::from_millis(70)).await;

assert!(!pool.locked().idle.contains_key(&key));
}
Expand Down
Loading