fn ensure_min_connections_in_pool(pool: &ConnectionPool) {
    if let Some(min_pool_size) = pool.inner.min_pool_size {
        loop {
            let mut connections = pool.inner.connections.write().unwrap();

            if pool.inner.total_connection_count.load(Ordering::SeqCst) < min_pool_size {
                match pool.create_connection(false) {
                    Ok(connection) => connections.push(connection),
                    e @ Err(_) => {
                        // Since we had to clear the pool, we return early from this function and
                        // put the background thread back to sleep. Next time it wakes up, the
                        // stale connections will be closed, and the thread can try to create new
                        // ones after that.
                        return;
                    }
                }
            } else {
                return;
            }
        }
    }
}
/// Add connections until the min pool size it met. We explicitly release the lock at the end of
/// each iteration and acquire it again during the next one to ensure that the this method doesn't
/// block other threads from acquiring connections.
Add connections until the min pool size it met. We explicitly release the lock at the end of
each iteration and acquire it again during the next one to ensure that the this method doesn't
block other threads from acquiring connections.
Add connections until the min pool size it met . We explicitly release the lock at the end of each iteration and acquire it again during the next one to ensure that the this method doesn ' t block other threads from acquiring connections .
fn ensure_min_connections_in_pool(pool: &ConnectionPool) {
    if let Some(min_pool_size) = pool.inner.min_pool_size {
        loop {
            let mut connections = pool.inner.connections.write().unwrap();
            if pool.inner.total_connection_count.load(Ordering::SeqCst) < min_pool_size {
                match pool.create_connection(false) {
                    Ok(connection) => connections.push(connection),
                    e @ Err(_) => {
                        // Since we had to clear the pool, we return early from this function and
                        // put the background thread back to sleep. Next time it wakes up, the
                        // stale connections will be closed, and the thread can try to create new
                        // ones after that.
                        return;
                    }
                }
            } else {
                return;
            }
        }
    }
}
fn ensure_min_connections_in_pool ( pool : & ConnectionPool ) { if let Some ( min_pool_size ) = pool . inner . min_pool_size { loop { let mut connections = pool . inner . connections . write ( ) . unwrap ( ) ; if pool . inner . total_connection_count . load ( Ordering :: SeqCst ) < min_pool_size { match pool . create_connection ( false ) { Ok ( connection ) => connections . push ( connection ) , e @ Err ( _ ) => { // Since we had to clear the pool, we return early from this function and // put the background thread back to sleep. Next time it wakes up, the // stale connections will be closed, and the thread can try to create new // ones after that. return ; } } } else { return ; } } } }
Add connections until the min pool size it met.
Add connections until the min pool size it met .
pool
&ConnectionPool
pool
&ConnectionPool