pub async fn resize(&mut self, new_max_size: usize) {
        let _guard = self.resize_mutex.lock().await;
        if new_max_size > self.capacity() {
            let diff = new_max_size - self.capacity();
            self.capacity.fetch_add(diff, Ordering::Relaxed);
            self.push_semaphore.add_permits(diff);
        } else if new_max_size < self.capacity() {
            for _ in self.capacity()..new_max_size {
                let permit = self.push_semaphore.acquire().await.unwrap();
                self.capacity.fetch_sub(1, Ordering::Relaxed);
                permit.forget();
                self.base.pop().await;
            }
        }
    }
/// Resize queue. This increases or decreases the queue
/// capacity accordingly.
///
/// **Note:** Increasing the capacity of a queue happens without
/// blocking unless a resize operation is already in progress.
/// Decreasing the capacity can block if there are futures waiting to
/// push items to the queue.
Resize queue. This increases or decreases the queue
capacity accordingly.

Increasing the capacity of a queue happens without
blocking unless a resize operation is already in progress.
Decreasing the capacity can block if there are futures waiting to
push items to the queue.
Resize queue . This increases or decreases the queue capacity accordingly . Increasing the capacity of a queue happens without blocking unless a resize operation is already in progress . Decreasing the capacity can block if there are futures waiting to push items to the queue .
pub async fn resize(&mut self, new_max_size: usize) {
        let _guard = self.resize_mutex.lock().await;
        if new_max_size > self.capacity() {
            let diff = new_max_size - self.capacity();
            self.capacity.fetch_add(diff, Ordering::Relaxed);
            self.push_semaphore.add_permits(diff);
        } else if new_max_size < self.capacity() {
            for _ in self.capacity()..new_max_size {
                let permit = self.push_semaphore.acquire().await.unwrap();
                self.capacity.fetch_sub(1, Ordering::Relaxed);
                permit.forget();
                self.base.pop().await;
            }
        }
    }
pub async fn resize ( & mut self , new_max_size : usize ) { let _guard = self . resize_mutex . lock ( ) . await ; if new_max_size > self . capacity ( ) { let diff = new_max_size - self . capacity ( ) ; self . capacity . fetch_add ( diff , Ordering :: Relaxed ) ; self . push_semaphore . add_permits ( diff ) ; } else if new_max_size < self . capacity ( ) { for _ in self . capacity ( ) .. new_max_size { let permit = self . push_semaphore . acquire ( ) . await . unwrap ( ) ; self . capacity . fetch_sub ( 1 , Ordering :: Relaxed ) ; permit . forget ( ) ; self . base . pop ( ) . await ; } } }
Resize queue.
Resize queue .
&mut self
new_max_size
usize
&mut self
new_max_size
usize