fn search(&self) -> Option<Runnable> {
        if let Some(r) = self.shard.pop() {
            return Some(r);
        }

        // Try stealing from the global queue.
        if let Some(r) = self.global.queue.pop() {
            return Some(r);
        }

        // Try stealing from other shards.
        let shards = self.global.shards.read().unwrap();

        // Pick a random starting point in the iterator list and rotate the list.
        let n = shards.len();
        let start = rand::thread_rng().gen_range(0..n);
        let iter = shards
            .iter()
            .chain(shards.iter())
            .skip(start)
            .take(n)
            .filter(|shard| !Arc::ptr_eq(shard, &self.shard));

        // Try stealing from each shard in the list.
        for shard in iter {
            steal(shard, &self.shard);
            if let Some(r) = self.shard.pop() {
                return Some(r);
            }
        }
        None
    }
/// Finds the next task to run.
Finds the next task to run.
Finds the next task to run .
fn search(&self) -> Option<Runnable> {
        if let Some(r) = self.shard.pop() {
            return Some(r);
        }
        // Try stealing from the global queue.
        if let Some(r) = self.global.queue.pop() {
            return Some(r);
        }
        // Try stealing from other shards.
        let shards = self.global.shards.read().unwrap();
        // Pick a random starting point in the iterator list and rotate the list.
        let n = shards.len();
        let start = rand::thread_rng().gen_range(0..n);
        let iter = shards
            .iter()
            .chain(shards.iter())
            .skip(start)
            .take(n)
            .filter(|shard| !Arc::ptr_eq(shard, &self.shard));
        // Try stealing from each shard in the list.
        for shard in iter {
            steal(shard, &self.shard);
            if let Some(r) = self.shard.pop() {
                return Some(r);
            }
        }
        None
    }
fn search ( & self ) -> Option < Runnable > { if let Some ( r ) = self . shard . pop ( ) { return Some ( r ) ; } // Try stealing from the global queue. if let Some ( r ) = self . global . queue . pop ( ) { return Some ( r ) ; } // Try stealing from other shards. let shards = self . global . shards . read ( ) . unwrap ( ) ; // Pick a random starting point in the iterator list and rotate the list. let n = shards . len ( ) ; let start = rand :: thread_rng ( ) . gen_range ( 0 .. n ) ; let iter = shards . iter ( ) . chain ( shards . iter ( ) ) . skip ( start ) . take ( n ) . filter ( | shard | ! Arc :: ptr_eq ( shard , & self . shard ) ) ; // Try stealing from each shard in the list. for shard in iter { steal ( shard , & self . shard ) ; if let Some ( r ) = self . shard . pop ( ) { return Some ( r ) ; } } None }
Finds the next task to run.
Finds the next task to run .
&self
&self