pub fn pop(&self) -> Pop<T> {
        // Load the back and front index.
        let b = self.inner.back.load(Ordering::Relaxed);
        let f = self.inner.front.load(Ordering::Relaxed);

        // Calculate the length of the deque.
        let len = b.wrapping_sub(f);

        // Is the deque empty?
        if len <= 0 {
            return Pop::Empty;
        }

        match self.flavor {
            // Pop from the front of the deque.
            Flavor::Fifo => {
                // Try incrementing the front index to pop the value.
                if self.inner
                    .front
                    .compare_exchange(f, f.wrapping_add(1), Ordering::SeqCst, Ordering::Relaxed)
                    .is_ok()
                {
                    unsafe {
                        // Read the popped value.
                        let buffer = self.cached_buffer.get();
                        let data = buffer.read(f);

                        // Shrink the buffer if `len - 1` is less than one fourth of the capacity.
                        if buffer.cap > MIN_CAP && len <= buffer.cap as isize / 4 {
                            self.resize(buffer.cap / 2);
                        }

                        return Pop::Data(data);
                    }
                }

                Pop::Retry
            }

            // Pop from the back of the deque.
            Flavor::Lifo => {
                // Decrement the back index.
                let b = b.wrapping_sub(1);
                self.inner.back.store(b, Ordering::Relaxed);

                atomic::fence(Ordering::SeqCst);

                // Load the front index.
                let f = self.inner.front.load(Ordering::Relaxed);

                // Compute the length after the back index was decremented.
                let len = b.wrapping_sub(f);

                if len < 0 {
                    // The deque is empty. Restore the back index to the original value.
                    self.inner.back.store(b.wrapping_add(1), Ordering::Relaxed);
                    Pop::Empty
                } else {
                    // Read the value to be popped.
                    let buffer = self.cached_buffer.get();
                    let mut value = unsafe { Some(buffer.read(b)) };

                    // Are we popping the last element from the deque?
                    if len == 0 {
                        // Try incrementing the front index.
                        if self.inner
                            .front
                            .compare_exchange(
                                f,
                                f.wrapping_add(1),
                                Ordering::SeqCst,
                                Ordering::Relaxed,
                            )
                            .is_err()
                        {
                            // Failed. We didn't pop anything.
                            mem::forget(value.take());
                        }

                        // Restore the back index to the original value.
                        self.inner.back.store(b.wrapping_add(1), Ordering::Relaxed);
                    } else {
                        // Shrink the buffer if `len` is less than one fourth of the capacity.
                        if buffer.cap > MIN_CAP && len < buffer.cap as isize / 4 {
                            unsafe {
                                self.resize(buffer.cap / 2);
                            }
                        }
                    }

                    match value {
                        None => Pop::Empty,
                        Some(data) => Pop::Data(data),
                    }
                }
            }
        }
    }
/// Pops an element from the deque.
///
/// Which end of the deque is used depends on the strategy:
///
/// * If this is a FIFO deque, an element is popped from the front.
/// * If this is a LIFO deque, an element is popped from the back.
///
/// # Examples
///
/// ```
/// use crossbeam_deque::{self as deque, Pop};
///
/// let (w, _) = deque::fifo();
/// w.push(1);
/// w.push(2);
///
/// assert_eq!(w.pop(), Pop::Data(1));
/// assert_eq!(w.pop(), Pop::Data(2));
/// assert_eq!(w.pop(), Pop::Empty);
/// ```
Pops an element from the deque.
Which end of the deque is used depends on the strategy.

If this is a FIFO deque, an element is popped from the front.
If this is a LIFO deque, an element is popped from the back.
Pops an element from the deque . Which end of the deque is used depends on the strategy . If this is a FIFO deque an element is popped from the front . If this is a LIFO deque an element is popped from the back .
pub fn pop(&self) -> Pop<T> {
        // Load the back and front index.
        let b = self.inner.back.load(Ordering::Relaxed);
        let f = self.inner.front.load(Ordering::Relaxed);
        // Calculate the length of the deque.
        let len = b.wrapping_sub(f);
        // Is the deque empty?
        if len <= 0 {
            return Pop::Empty;
        }
        match self.flavor {
            // Pop from the front of the deque.
            Flavor::Fifo => {
                // Try incrementing the front index to pop the value.
                if self.inner
                    .front
                    .compare_exchange(f, f.wrapping_add(1), Ordering::SeqCst, Ordering::Relaxed)
                    .is_ok()
                {
                    unsafe {
                        // Read the popped value.
                        let buffer = self.cached_buffer.get();
                        let data = buffer.read(f);
                        // Shrink the buffer if `len - 1` is less than one fourth of the capacity.
                        if buffer.cap > MIN_CAP && len <= buffer.cap as isize / 4 {
                            self.resize(buffer.cap / 2);
                        }
                        return Pop::Data(data);
                    }
                }
                Pop::Retry
            }
            // Pop from the back of the deque.
            Flavor::Lifo => {
                // Decrement the back index.
                let b = b.wrapping_sub(1);
                self.inner.back.store(b, Ordering::Relaxed);
                atomic::fence(Ordering::SeqCst);
                // Load the front index.
                let f = self.inner.front.load(Ordering::Relaxed);
                // Compute the length after the back index was decremented.
                let len = b.wrapping_sub(f);
                if len < 0 {
                    // The deque is empty. Restore the back index to the original value.
                    self.inner.back.store(b.wrapping_add(1), Ordering::Relaxed);
                    Pop::Empty
                } else {
                    // Read the value to be popped.
                    let buffer = self.cached_buffer.get();
                    let mut value = unsafe { Some(buffer.read(b)) };
                    // Are we popping the last element from the deque?
                    if len == 0 {
                        // Try incrementing the front index.
                        if self.inner
                            .front
                            .compare_exchange(
                                f,
                                f.wrapping_add(1),
                                Ordering::SeqCst,
                                Ordering::Relaxed,
                            )
                            .is_err()
                        {
                            // Failed. We didn't pop anything.
                            mem::forget(value.take());
                        }
                        // Restore the back index to the original value.
                        self.inner.back.store(b.wrapping_add(1), Ordering::Relaxed);
                    } else {
                        // Shrink the buffer if `len` is less than one fourth of the capacity.
                        if buffer.cap > MIN_CAP && len < buffer.cap as isize / 4 {
                            unsafe {
                                self.resize(buffer.cap / 2);
                            }
                        }
                    }
                    match value {
                        None => Pop::Empty,
                        Some(data) => Pop::Data(data),
                    }
                }
            }
        }
    }
pub fn pop ( & self ) -> Pop < T > { // Load the back and front index. let b = self . inner . back . load ( Ordering :: Relaxed ) ; let f = self . inner . front . load ( Ordering :: Relaxed ) ; // Calculate the length of the deque. let len = b . wrapping_sub ( f ) ; // Is the deque empty? if len <= 0 { return Pop :: Empty ; } match self . flavor { // Pop from the front of the deque. Flavor :: Fifo => { // Try incrementing the front index to pop the value. if self . inner . front . compare_exchange ( f , f . wrapping_add ( 1 ) , Ordering :: SeqCst , Ordering :: Relaxed ) . is_ok ( ) { unsafe { // Read the popped value. let buffer = self . cached_buffer . get ( ) ; let data = buffer . read ( f ) ; // Shrink the buffer if `len - 1` is less than one fourth of the capacity. if buffer . cap > MIN_CAP && len <= buffer . cap as isize / 4 { self . resize ( buffer . cap / 2 ) ; } return Pop :: Data ( data ) ; } } Pop :: Retry } // Pop from the back of the deque. Flavor :: Lifo => { // Decrement the back index. let b = b . wrapping_sub ( 1 ) ; self . inner . back . store ( b , Ordering :: Relaxed ) ; atomic :: fence ( Ordering :: SeqCst ) ; // Load the front index. let f = self . inner . front . load ( Ordering :: Relaxed ) ; // Compute the length after the back index was decremented. let len = b . wrapping_sub ( f ) ; if len < 0 { // The deque is empty. Restore the back index to the original value. self . inner . back . store ( b . wrapping_add ( 1 ) , Ordering :: Relaxed ) ; Pop :: Empty } else { // Read the value to be popped. let buffer = self . cached_buffer . get ( ) ; let mut value = unsafe { Some ( buffer . read ( b ) ) } ; // Are we popping the last element from the deque? if len == 0 { // Try incrementing the front index. if self . inner . front . compare_exchange ( f , f . wrapping_add ( 1 ) , Ordering :: SeqCst , Ordering :: Relaxed , ) . is_err ( ) { // Failed. We didn't pop anything. mem :: forget ( value . take ( ) ) ; } // Restore the back index to the original value. self . inner . back . store ( b . wrapping_add ( 1 ) , Ordering :: Relaxed ) ; } else { // Shrink the buffer if `len` is less than one fourth of the capacity. if buffer . cap > MIN_CAP && len < buffer . cap as isize / 4 { unsafe { self . resize ( buffer . cap / 2 ) ; } } } match value { None => Pop :: Empty , Some ( data ) => Pop :: Data ( data ) , } } } } }
Pops an element from the deque.
Pops an element from the deque .
&self
&self
examples
```
use crossbeam_deque::{self as deque, Pop}.




` ` ` use crossbeam_deque :: { self as deque Pop } .