Skip to content

Commit

Permalink
Inline PoolInner::reap()
Browse files Browse the repository at this point in the history
  • Loading branch information
djc committed Jan 29, 2024
1 parent 4cf6cc1 commit 4c2ea49
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions bb8/src/inner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,6 @@ where
self.inner.internals.lock().state()
}

fn reap(&self) {
let mut internals = self.inner.internals.lock();
let approvals = internals.reap(&self.inner.statics);
self.spawn_replenishing_approvals(approvals);
}

// Outside of Pool to avoid borrow splitting issues on self
async fn add_connection(&self, approval: Approval) -> Result<(), M::Error>
where
Expand Down Expand Up @@ -238,11 +232,16 @@ impl<M: ManageConnection> Reaper<M> {
async fn run(mut self) {
loop {
let _ = self.interval.tick().await;
if let Some(inner) = self.pool.upgrade() {
PoolInner { inner }.reap();
} else {
break;
}
let pool = match self.pool.upgrade() {
Some(inner) => PoolInner { inner },
None => break,
};

let mut locked = pool.inner.internals.lock();
let approvals = locked.reap(&pool.inner.statics);
drop(locked);

pool.spawn_replenishing_approvals(approvals);
}
}
}

0 comments on commit 4c2ea49

Please sign in to comment.