pub(super) fn wait_until_at_front(&self) -> Result<WaitQueueHandle> {
        let mut guard = self.inner.lock().unwrap();

        let condvar = Arc::new(Condvar::new());
        guard.queue.push_back(condvar.clone());

        // If we're already at the front of the wait queue, we don't need to wait. We don't pop
        // ourself off of the wait queue yet though, since another thread may enter while we're
        // waiting for a connection to become available.
        if guard.queue.len() == 1 {
            return Ok(WaitQueueHandle::new(guard, condvar));
        }

        let guard = if let Some(timeout) = guard.timeout {
            // Wait until all of the WaitQueueHandles in the queue in front of the current thread's
            // are dropped or a timeout occurs.
            let (guard, result) = condvar.wait_timeout(guard, timeout).unwrap();

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

            guard
        } else {
            // Wait until all of the WaitQueueHandles in the queue in front of the current thread's
            // are dropped.
            condvar.wait(guard).unwrap()
        };

        Ok(WaitQueueHandle::new(guard, condvar))
    }
/// Enters the wait queue and blocks until it either reaches the front of the queue or the
/// timeout has elapsed.
Enters the wait queue and blocks until it either reaches the front of the queue or the
timeout has elapsed.
Enters the wait queue and blocks until it either reaches the front of the queue or the timeout has elapsed .
pub(super) fn wait_until_at_front(&self) -> Result<WaitQueueHandle> {
        let mut guard = self.inner.lock().unwrap();
        let condvar = Arc::new(Condvar::new());
        guard.queue.push_back(condvar.clone());
        // If we're already at the front of the wait queue, we don't need to wait. We don't pop
        // ourself off of the wait queue yet though, since another thread may enter while we're
        // waiting for a connection to become available.
        if guard.queue.len() == 1 {
            return Ok(WaitQueueHandle::new(guard, condvar));
        }
        let guard = if let Some(timeout) = guard.timeout {
            // Wait until all of the WaitQueueHandles in the queue in front of the current thread's
            // are dropped or a timeout occurs.
            let (guard, result) = condvar.wait_timeout(guard, timeout).unwrap();
            if result.timed_out() {
                return Err(ErrorKind::WaitQueueTimeoutError {
                    address: guard.address.clone(),
                }
                .into());
            }
            guard
        } else {
            // Wait until all of the WaitQueueHandles in the queue in front of the current thread's
            // are dropped.
            condvar.wait(guard).unwrap()
        };
        Ok(WaitQueueHandle::new(guard, condvar))
    }
pub ( super ) fn wait_until_at_front ( & self ) -> Result < WaitQueueHandle > { let mut guard = self . inner . lock ( ) . unwrap ( ) ; let condvar = Arc :: new ( Condvar :: new ( ) ) ; guard . queue . push_back ( condvar . clone ( ) ) ; // If we're already at the front of the wait queue, we don't need to wait. We don't pop // ourself off of the wait queue yet though, since another thread may enter while we're // waiting for a connection to become available. if guard . queue . len ( ) == 1 { return Ok ( WaitQueueHandle :: new ( guard , condvar ) ) ; } let guard = if let Some ( timeout ) = guard . timeout { // Wait until all of the WaitQueueHandles in the queue in front of the current thread's // are dropped or a timeout occurs. let ( guard , result ) = condvar . wait_timeout ( guard , timeout ) . unwrap ( ) ; if result . timed_out ( ) { return Err ( ErrorKind :: WaitQueueTimeoutError { address : guard . address . clone ( ) , } . into ( ) ) ; } guard } else { // Wait until all of the WaitQueueHandles in the queue in front of the current thread's // are dropped. condvar . wait ( guard ) . unwrap ( ) } ; Ok ( WaitQueueHandle :: new ( guard , condvar ) ) }
Enters the wait queue and blocks until it either reaches the front of the queue or the
timeout has elapsed.
Enters the wait queue and blocks until it either reaches the front of the queue or the timeout has elapsed .
&self
&self