unsafe fn steal(&self) -> Option<JobRef> {
        // we only steal when we don't have any work to do locally
        debug_assert!(self.is_local_queue_empty());

        // otherwise, try to steal
        let thread_infos = &self.registry.thread_infos.as_slice();
        let num_threads = thread_infos.len();
        if num_threads <= 1 {
            return None;
        }

        loop {
            let mut retry = false;
            let start = self.rng.next_usize(num_threads);
            let job = (start..num_threads)
                .chain(0..start)
                .filter(move |&i| i != self.id)
                .find_map(|victim_index| {
                    let victim = &thread_infos[victim_index];
                    match victim.stealer.steal() {
                        Steal::Success(job) => {
                            // self.log(|| JobStolen {
                            //     worker: self.index,
                            //     victim: victim_index,
                            // });
                            Some(job)
                        }
                        Steal::Empty => None,
                        Steal::Retry => {
                            retry = true;
                            None
                        }
                    }
                });
            if job.is_some() || !retry {
                return job;
            }
        }
    }
/// Try to steal a single job and return it.
///
/// This should only be done as a last resort, when there is no
/// local work to do.
Try to steal a single job and return it.
This should only be done as a last resort, when there is no
local work to do.
Try to steal a single job and return it . This should only be done as a last resort when there is no local work to do .
unsafe fn steal(&self) -> Option<JobRef> {
        // we only steal when we don't have any work to do locally
        debug_assert!(self.is_local_queue_empty());
        // otherwise, try to steal
        let thread_infos = &self.registry.thread_infos.as_slice();
        let num_threads = thread_infos.len();
        if num_threads <= 1 {
            return None;
        }
        loop {
            let mut retry = false;
            let start = self.rng.next_usize(num_threads);
            let job = (start..num_threads)
                .chain(0..start)
                .filter(move |&i| i != self.id)
                .find_map(|victim_index| {
                    let victim = &thread_infos[victim_index];
                    match victim.stealer.steal() {
                        Steal::Success(job) => {
                            // self.log(|| JobStolen {
                            //     worker: self.index,
                            //     victim: victim_index,
                            // });
                            Some(job)
                        }
                        Steal::Empty => None,
                        Steal::Retry => {
                            retry = true;
                            None
                        }
                    }
                });
            if job.is_some() || !retry {
                return job;
            }
        }
    }
unsafe fn steal ( & self ) -> Option < JobRef > { // we only steal when we don't have any work to do locally debug_assert ! ( self is_local_queue_empty ( ) ) ; // otherwise, try to steal let thread_infos = & self . registry . thread_infos . as_slice ( ) ; let num_threads = thread_infos . len ( ) ; if num_threads <= 1 { return None ; } loop { let mut retry = false ; let start = self . rng . next_usize ( num_threads ) ; let job = ( start .. num_threads ) . chain ( 0 .. start ) . filter ( move | & i | i != self . id ) . find_map ( | victim_index | { let victim = & thread_infos [ victim_index ] ; match victim . stealer . steal ( ) { Steal :: Success ( job ) => { // self.log(|| JobStolen { //     worker: self.index, //     victim: victim_index, // }); Some ( job ) } Steal :: Empty => None , Steal :: Retry => { retry = true ; None } } } ) ; if job . is_some ( ) || ! retry { return job ; } } }
Try to steal a single job and return it.
Try to steal a single job and return it .
&self
&self