Add size() and num_idle()

This commit is contained in:
Joshua Nelson 2020-09-24 20:28:51 -04:00 committed by Ryan Leckey
parent d0ccb4d0b2
commit 2be4601150

View file

@ -145,6 +145,20 @@ impl<DB: Database> Pool<DB> {
pub fn is_closed(&self) -> bool { pub fn is_closed(&self) -> bool {
self.0.is_closed() self.0.is_closed()
} }
/// Returns the number of connections currently active. This includes idle connections.
pub fn size(&self) -> u32 {
self.0.size()
}
/// Returns the number of connections active and idle (not in use).
///
/// This will block until the number of connections stops changing for at
/// least 2 atomic accesses in a row. If the number of idle connections is
/// changing rapidly, this may run indefinitely.
pub fn num_idle(&self) -> usize {
self.0.num_idle()
}
} }
/// Returns a new [Pool] tied to the same shared connection pool. /// Returns a new [Pool] tied to the same shared connection pool.