fn estimate_realloc_capacity( &self ) -> Option< ( usize, usize ) > {
        let mut inner = self.inner.borrow_mut();

        let cap = inner.queue.capacity();

        inner.past_sum += inner.queue.len();
        inner.past_length += 1;

        let average = inner.past_sum / inner.past_length;

        // It will resize the queue if the average length is less than a quarter of the
        // capacity.
        //
        // The check for INITIAL_QUEUE_CAPACITY is necessary in the situation
        // where the queue is at its initial capacity, but the length is very low.
        if average < cap / 4 && cap >= INITIAL_QUEUE_CAPACITY * 2 {
            // It only resizes if the above condition is met for QUEUE_SHRINK_DELAY iterations.
            inner.shrink_counter += 1;

            if inner.shrink_counter >= QUEUE_SHRINK_DELAY {
                inner.shrink_counter = 0;
                return Some( ( cap, cmp::max( average * 2, INITIAL_QUEUE_CAPACITY ) ) );
            }

        } else {
            inner.shrink_counter = 0;
        }

        None
    }
// See if it's worth trying to reclaim some space from the queue
See if it's worth trying to reclaim some space from the queue
See if it ' s worth trying to reclaim some space from the queue
fn estimate_realloc_capacity( &self ) -> Option< ( usize, usize ) > {
        let mut inner = self.inner.borrow_mut();
        let cap = inner.queue.capacity();
        inner.past_sum += inner.queue.len();
        inner.past_length += 1;
        let average = inner.past_sum / inner.past_length;
        // It will resize the queue if the average length is less than a quarter of the
        // capacity.
        //
        // The check for INITIAL_QUEUE_CAPACITY is necessary in the situation
        // where the queue is at its initial capacity, but the length is very low.
        if average < cap / 4 && cap >= INITIAL_QUEUE_CAPACITY * 2 {
            // It only resizes if the above condition is met for QUEUE_SHRINK_DELAY iterations.
            inner.shrink_counter += 1;
            if inner.shrink_counter >= QUEUE_SHRINK_DELAY {
                inner.shrink_counter = 0;
                return Some( ( cap, cmp::max( average * 2, INITIAL_QUEUE_CAPACITY ) ) );
            }
        } else {
            inner.shrink_counter = 0;
        }
        None
    }
fn estimate_realloc_capacity ( & self ) -> Option < ( usize , usize ) > { let mut inner = self . inner . borrow_mut ( ) ; let cap = inner . queue . capacity ( ) ; inner . past_sum += inner . queue . len ( ) ; inner . past_length += 1 ; let average = inner . past_sum / inner . past_length ; // It will resize the queue if the average length is less than a quarter of the // capacity. // // The check for INITIAL_QUEUE_CAPACITY is necessary in the situation // where the queue is at its initial capacity, but the length is very low. if average < cap / 4 && cap >= INITIAL_QUEUE_CAPACITY * 2 { // It only resizes if the above condition is met for QUEUE_SHRINK_DELAY iterations. inner . shrink_counter += 1 ; if inner . shrink_counter >= QUEUE_SHRINK_DELAY { inner . shrink_counter = 0 ; return Some ( ( cap , cmp :: max ( average * 2 , INITIAL_QUEUE_CAPACITY ) ) ) ; } } else { inner . shrink_counter = 0 ; } None }
See if it's worth trying to reclaim some space from the queue
See if it ' s worth trying to reclaim some space from the queue
&self
&self