/// Pushes a task into the queue.
Pushes a task into the queue.
Pushes a task into the queue .
pub fn push(&self, task: T) {
        // Load the back index, front index, and buffer.
        let b = self.inner.back.load(Ordering::Relaxed);
        let f = self.inner.front.load(Ordering::Acquire);
        let mut buffer = self.buffer.get();
        // Calculate the length of the queue.
        let len = b.wrapping_sub(f);
        // Is the queue full?
        if len >= buffer.cap as isize {
            // Yes. Grow the underlying buffer.
            unsafe {
                self.resize(2 * buffer.cap);
            }
            buffer = self.buffer.get();
        }
        // Write `task` into the slot.
        unsafe {
            buffer.write(b, task);
        }
        atomic::fence(Ordering::Release);
        // Increment the back index.
        //
        // This ordering could be `Relaxed`, but then thread sanitizer would falsely report data
        // races because it doesn't understand fences.
        self.inner.back.store(b.wrapping_add(1), Ordering::Release);
    }
pub fn push ( & self , task : T ) { // Load the back index, front index, and buffer. let b = self . inner . back . load ( Ordering :: Relaxed ) ; let f = self . inner . front . load ( Ordering :: Acquire ) ; let mut buffer = self . buffer . get ( ) ; // Calculate the length of the queue. let len = b . wrapping_sub ( f ) ; // Is the queue full? if len >= buffer . cap as isize { // Yes. Grow the underlying buffer. unsafe { self . resize ( 2 * buffer . cap ) ; } buffer = self . buffer . get ( ) ; } // Write `task` into the slot. unsafe { buffer . write ( b , task ) ; } atomic :: fence ( Ordering :: Release ) ; // Increment the back index. // // This ordering could be `Relaxed`, but then thread sanitizer would falsely report data // races because it doesn't understand fences. self . inner . back . store ( b . wrapping_add ( 1 ) , Ordering :: Release ) ; }
Pushes a task into the queue.
Pushes a task into the queue .
&self
task
T