pub(super) fn wait_for_available_connection(
        &mut self,
        timeout: Option<Duration>,
    ) -> Result<()> {
        // Temporarily remove the mutex guard from the field so that we can pass ownership of it to
        // the conditional variable.
        let guard = self.guard.take().unwrap();

        if let Some(timeout) = timeout {
            // Wait until a connection is checked back in or the timeout has elapsed.
            let (guard, result) = self.condvar.wait_timeout(guard, timeout).unwrap();

            if result.timed_out() {
                return Err(ErrorKind::WaitQueueTimeoutError {
                    address: guard.address.clone(),
                }
                .into());
            }

            self.guard = Some(guard);
        } else {
            // Wait until a connection is checked back in.
            self.guard = Some(self.condvar.wait(guard).unwrap());
        }

        Ok(())
    }
/// Blocks on the internal conditional variable until either the conditional variable is
/// notified (which indicates that a connection is ready) or a timeout occurs.
Blocks on the internal conditional variable until either the conditional variable is
notified (which indicates that a connection is ready) or a timeout occurs.
Blocks on the internal conditional variable until either the conditional variable is notified ( which indicates that a connection is ready ) or a timeout occurs .
pub(super) fn wait_for_available_connection(
        &mut self,
        timeout: Option<Duration>,
    ) -> Result<()> {
        // Temporarily remove the mutex guard from the field so that we can pass ownership of it to
        // the conditional variable.
        let guard = self.guard.take().unwrap();
        if let Some(timeout) = timeout {
            // Wait until a connection is checked back in or the timeout has elapsed.
            let (guard, result) = self.condvar.wait_timeout(guard, timeout).unwrap();
            if result.timed_out() {
                return Err(ErrorKind::WaitQueueTimeoutError {
                    address: guard.address.clone(),
                }
                .into());
            }
            self.guard = Some(guard);
        } else {
            // Wait until a connection is checked back in.
            self.guard = Some(self.condvar.wait(guard).unwrap());
        }
        Ok(())
    }
pub ( super ) fn wait_for_available_connection ( & mut self , timeout : Option < Duration > , ) -> Result < ( ) > { // Temporarily remove the mutex guard from the field so that we can pass ownership of it to // the conditional variable. let guard = self . guard . take ( ) . unwrap ( ) ; if let Some ( timeout ) = timeout { // Wait until a connection is checked back in or the timeout has elapsed. let ( guard , result ) = self . condvar . wait_timeout ( guard , timeout ) . unwrap ( ) ; if result . timed_out ( ) { return Err ( ErrorKind :: WaitQueueTimeoutError { address : guard . address . clone ( ) , } . into ( ) ) ; } self . guard = Some ( guard ) ; } else { // Wait until a connection is checked back in. self . guard = Some ( self . condvar . wait ( guard ) . unwrap ( ) ) ; } Ok ( ( ) ) }
Blocks on the internal conditional variable until either the conditional variable is
notified (which indicates that a connection is ready) or a timeout occurs.
Blocks on the internal conditional variable until either the conditional variable is notified ( which indicates that a connection is ready ) or a timeout occurs .
&mut self
timeout
Option<Duration>
&mut self
timeout
Option<Duration>