fn search(&self) -> Option<Runnable> {
        if self.ticker.get() % 2 == 0 {
            // On even ticks, look into the local queue and then into the shard.
            if let Ok(r) = self.local.pop().or_else(|_| self.shard.pop()) {
                return Some(r);
            }
        } else {
            // On odd ticks, look into the shard and then into the local queue.
            if let Ok(r) = self.shard.pop().or_else(|_| self.local.pop()) {
                return Some(r);
            }
        }

        // Try stealing from the global queue.
        steal(&self.global.queue, &self.shard);
        if let Ok(r) = self.shard.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 = fastrand::usize(..n);
        let iter = shards.iter().chain(shards.iter()).skip(start).take(n);

        // Remove this worker's shard.
        let iter = iter.filter(|(key, _)| *key != self.key);
        let iter = iter.map(|(_, shard)| shard);

        // Try stealing from each shard in the list.
        for shard in iter {
            steal(shard, &self.shard);
            if let Ok(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 self.ticker.get() % 2 == 0 {
            // On even ticks, look into the local queue and then into the shard.
            if let Ok(r) = self.local.pop().or_else(|_| self.shard.pop()) {
                return Some(r);
            }
        } else {
            // On odd ticks, look into the shard and then into the local queue.
            if let Ok(r) = self.shard.pop().or_else(|_| self.local.pop()) {
                return Some(r);
            }
        }
        // Try stealing from the global queue.
        steal(&self.global.queue, &self.shard);
        if let Ok(r) = self.shard.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 = fastrand::usize(..n);
        let iter = shards.iter().chain(shards.iter()).skip(start).take(n);
        // Remove this worker's shard.
        let iter = iter.filter(|(key, _)| *key != self.key);
        let iter = iter.map(|(_, shard)| shard);
        // Try stealing from each shard in the list.
        for shard in iter {
            steal(shard, &self.shard);
            if let Ok(r) = self.shard.pop() {
                return Some(r);
            }
        }
        None
    }
fn search ( & self ) -> Option < Runnable > { if self . ticker . get ( ) % 2 == 0 { // On even ticks, look into the local queue and then into the shard. if let Ok ( r ) = self . local . pop ( ) . or_else ( | _ | self . shard . pop ( ) ) { return Some ( r ) ; } } else { // On odd ticks, look into the shard and then into the local queue. if let Ok ( r ) = self . shard . pop ( ) . or_else ( | _ | self . local . pop ( ) ) { return Some ( r ) ; } } // Try stealing from the global queue. steal ( & self . global . queue , & self . shard ) ; if let Ok ( r ) = self . shard . 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 = fastrand :: usize ( .. n ) ; let iter = shards . iter ( ) . chain ( shards . iter ( ) ) . skip ( start ) . take ( n ) ; // Remove this worker's shard. let iter = iter . filter ( | ( key , _ ) | * key != self . key ) ; let iter = iter . map ( | ( _ , shard ) | shard ) ; // Try stealing from each shard in the list. for shard in iter { steal ( shard , & self . shard ) ; if let Ok ( r ) = self . shard . pop ( ) { return Some ( r ) ; } } None }
Finds the next task to run.
Finds the next task to run .
&self