fn reserve(&self, reserve_cap: usize) {
        if reserve_cap > 0 {
            // Compute the current length.
            let b = self.inner.back.load(Ordering::Relaxed);
            let f = self.inner.front.load(Ordering::SeqCst);
            let len = b.wrapping_sub(f) as usize;

            // The current capacity.
            let cap = self.cached_buffer.get().cap;

            // Is there enough capacity to push `reserve_cap` elements?
            if cap - len < reserve_cap {
                // Keep doubling the capacity as much as is needed.
                let mut new_cap = cap * 2;
                while new_cap - len < reserve_cap {
                    new_cap *= 2;
                }

                // Resize the buffer.
                unsafe {
                    self.resize(new_cap);
                }
            }
        }
    }
/// Reserves enough capacity so that `reserve_cap` elements can be pushed without growing the
/// buffer.
Reserves enough capacity so that `reserve_cap` elements can be pushed without growing the
buffer.
Reserves enough capacity so that ` reserve_cap ` elements can be pushed without growing the buffer .
fn reserve(&self, reserve_cap: usize) {
        if reserve_cap > 0 {
            // Compute the current length.
            let b = self.inner.back.load(Ordering::Relaxed);
            let f = self.inner.front.load(Ordering::SeqCst);
            let len = b.wrapping_sub(f) as usize;
            // The current capacity.
            let cap = self.cached_buffer.get().cap;
            // Is there enough capacity to push `reserve_cap` elements?
            if cap - len < reserve_cap {
                // Keep doubling the capacity as much as is needed.
                let mut new_cap = cap * 2;
                while new_cap - len < reserve_cap {
                    new_cap *= 2;
                }
                // Resize the buffer.
                unsafe {
                    self.resize(new_cap);
                }
            }
        }
    }
fn reserve ( & self , reserve_cap : usize ) { if reserve_cap > 0 { // Compute the current length. let b = self . inner . back . load ( Ordering :: Relaxed ) ; let f = self . inner . front . load ( Ordering :: SeqCst ) ; let len = b . wrapping_sub ( f ) as usize ; // The current capacity. let cap = self . cached_buffer . get ( ) . cap ; // Is there enough capacity to push `reserve_cap` elements? if cap - len < reserve_cap { // Keep doubling the capacity as much as is needed. let mut new_cap = cap * 2 ; while new_cap - len < reserve_cap { new_cap *= 2 ; } // Resize the buffer. unsafe { self . resize ( new_cap ) ; } } } }
Reserves enough capacity so that `reserve_cap` elements can be pushed without growing the
buffer.
Reserves enough capacity so that ` reserve_cap ` elements can be pushed without growing the buffer .
&self
reserve_cap
usize
&self
reserve_cap
usize