pub(super) fn steal_into(&self, dst: &mut Local<T>) -> Option<task::Notified<T>> {
        // Safety: the caller is the only thread that mutates `dst.tail` and
        // holds a mutable reference.
        let dst_tail = unsafe { dst.inner.tail.unsync_load() };

        // To the caller, `dst` may **look** empty but still have values
        // contained in the buffer. If another thread is concurrently stealing
        // from `dst` there may not be enough capacity to steal.
        let (steal, _) = unpack(dst.inner.head.load(Acquire));

        if dst_tail.wrapping_sub(steal) > LOCAL_QUEUE_CAPACITY as u16 / 2 {
            // we *could* try to steal less here, but for simplicity, we're just
            // going to abort.
            return None;
        }

        // Steal the tasks into `dst`'s buffer. This does not yet expose the
        // tasks in `dst`.
        let mut n = self.steal_into2(dst, dst_tail);

        if n == 0 {
            // No tasks were stolen
            return None;
        }

        // We are returning a task here
        n -= 1;

        let ret_pos = dst_tail.wrapping_add(n);
        let ret_idx = ret_pos as usize & MASK;

        // safety: the value was written as part of `steal_into2` and not
        // exposed to stealers, so no other thread can access it.
        let ret = dst.inner.buffer[ret_idx].with(|ptr| unsafe { ptr::read((*ptr).as_ptr()) });

        if n == 0 {
            // The `dst` queue is empty, but a single task was stolen
            return Some(ret);
        }

        // Make the stolen items available to consumers
        dst.inner.tail.store(dst_tail.wrapping_add(n), Release);

        Some(ret)
    }
/// Steals half the tasks from self and place them into `dst`.
Steals half the tasks from self and place them into `dst`.
Steals half the tasks from self and place them into ` dst ` .
pub(super) fn steal_into(&self, dst: &mut Local<T>) -> Option<task::Notified<T>> {
        // Safety: the caller is the only thread that mutates `dst.tail` and
        // holds a mutable reference.
        let dst_tail = unsafe { dst.inner.tail.unsync_load() };
        // To the caller, `dst` may **look** empty but still have values
        // contained in the buffer. If another thread is concurrently stealing
        // from `dst` there may not be enough capacity to steal.
        let (steal, _) = unpack(dst.inner.head.load(Acquire));
        if dst_tail.wrapping_sub(steal) > LOCAL_QUEUE_CAPACITY as u16 / 2 {
            // we *could* try to steal less here, but for simplicity, we're just
            // going to abort.
            return None;
        }
        // Steal the tasks into `dst`'s buffer. This does not yet expose the
        // tasks in `dst`.
        let mut n = self.steal_into2(dst, dst_tail);
        if n == 0 {
            // No tasks were stolen
            return None;
        }
        // We are returning a task here
        n -= 1;
        let ret_pos = dst_tail.wrapping_add(n);
        let ret_idx = ret_pos as usize & MASK;
        // safety: the value was written as part of `steal_into2` and not
        // exposed to stealers, so no other thread can access it.
        let ret = dst.inner.buffer[ret_idx].with(|ptr| unsafe { ptr::read((*ptr).as_ptr()) });
        if n == 0 {
            // The `dst` queue is empty, but a single task was stolen
            return Some(ret);
        }
        // Make the stolen items available to consumers
        dst.inner.tail.store(dst_tail.wrapping_add(n), Release);
        Some(ret)
    }
pub ( super ) fn steal_into ( & self , dst : & mut Local < T > ) -> Option < task :: Notified < T > > { // Safety: the caller is the only thread that mutates `dst.tail` and // holds a mutable reference. let dst_tail = unsafe { dst . inner . tail . unsync_load ( ) } ; // To the caller, `dst` may **look** empty but still have values // contained in the buffer. If another thread is concurrently stealing // from `dst` there may not be enough capacity to steal. let ( steal , _ ) = unpack ( dst . inner . head . load ( Acquire ) ) ; if dst_tail . wrapping_sub ( steal ) > LOCAL_QUEUE_CAPACITY as u16 / 2 { // we *could* try to steal less here, but for simplicity, we're just // going to abort. return None ; } // Steal the tasks into `dst`'s buffer. This does not yet expose the // tasks in `dst`. let mut n = self . steal_into2 ( dst , dst_tail ) ; if n == 0 { // No tasks were stolen return None ; } // We are returning a task here n -= 1 ; let ret_pos = dst_tail . wrapping_add ( n ) ; let ret_idx = ret_pos as usize & MASK ; // safety: the value was written as part of `steal_into2` and not // exposed to stealers, so no other thread can access it. let ret = dst . inner . buffer [ ret_idx ] . with ( | ptr | unsafe { ptr :: read ( ( * ptr ) . as_ptr ( ) ) } ) ; if n == 0 { // The `dst` queue is empty, but a single task was stolen return Some ( ret ) ; } // Make the stolen items available to consumers dst . inner . tail . store ( dst_tail . wrapping_add ( n ) , Release ) ; Some ( ret ) }
Steals half the tasks from self and place them into `dst`.
Steals half the tasks from self and place them into ` dst ` .
&self
dst
&mut Local<T>
&self
dst
&mut Local<T>