Skip to content

Commit

Permalink
增加清除空闲池功能
Browse files Browse the repository at this point in the history
  • Loading branch information
tryor committed Jan 23, 2019
1 parent a2b1d8d commit 3cef365
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@ impl Client<(), Body> {
pub fn builder() -> Builder {
Builder::default()
}

//add by [email protected], 2019-01-23
///clear pool idles
pub fn clear_pool_idles(&self){
self.pool.clear_idles();
}
}

impl<C, B> Client<C, B>
Expand Down
15 changes: 15 additions & 0 deletions src/client/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,21 @@ impl<T: Poolable> Pool<T> {
})
}

//add by [email protected], 2019-01-23
pub(super) fn clear_idles(&self){
match self.inner.as_ref(){
Some(ref_inner) => {
match ref_inner.lock(){
Ok(mut inner) => {
inner.idle.clear();
},
_ => {}
}
},
None => {}
}
}

#[cfg(test)]
fn locked(&self) -> ::std::sync::MutexGuard<PoolInner<T>> {
self
Expand Down

0 comments on commit 3cef365

Please sign in to comment.