fn parked_executor(&self, id: usize) {
        // protect ourself from re-entry
        let _guard = self.barrier.lock();
        // dump state of all workers
        self.workers.read().iter().for_each(|(_, v)| {
            let state = v.get_state();
            log::debug!("worker {} {:#?}", v.id, state)
        });

        if let Some(worker) = self.workers.read().get(&id) {
            // at this point the worker thread won't load tasks into local queue, so drain it
            let mut count = 0;
            loop {
                match worker.stealer.steal() {
                    deque::Steal::Empty => break,
                    deque::Steal::Retry => (),
                    deque::Steal::Success(task) => {
                        count += 1;
                        self.run_queue.push(task)
                    },
                }
            }
            log::debug!("stole back {} tasks queue is_empty() = {}", count, self.run_queue.is_empty());
        }

        if let Some(worker) = self.workers.write().remove(&id) {
            // the executor will self-terminate
            // save the worker, otherwise it gets dropped things go wrong with join
            self.parked_workers.write().insert(id, worker);
            let dead_count = self.parked_workers.read().len();
            self.stats.lock().remove_worker(dead_count);
        }
        self.add_executor();
    }
// notification that an executor is parked
notification that an executor is parked
notification that an executor is parked
fn parked_executor(&self, id: usize) {
        // protect ourself from re-entry
        let _guard = self.barrier.lock();
        // dump state of all workers
        self.workers.read().iter().for_each(|(_, v)| {
            let state = v.get_state();
            log::debug!("worker {} {:#?}", v.id, state)
        });
        if let Some(worker) = self.workers.read().get(&id) {
            // at this point the worker thread won't load tasks into local queue, so drain it
            let mut count = 0;
            loop {
                match worker.stealer.steal() {
                    deque::Steal::Empty => break,
                    deque::Steal::Retry => (),
                    deque::Steal::Success(task) => {
                        count += 1;
                        self.run_queue.push(task)
                    },
                }
            }
            log::debug!("stole back {} tasks queue is_empty() = {}", count, self.run_queue.is_empty());
        }
        if let Some(worker) = self.workers.write().remove(&id) {
            // the executor will self-terminate
            // save the worker, otherwise it gets dropped things go wrong with join
            self.parked_workers.write().insert(id, worker);
            let dead_count = self.parked_workers.read().len();
            self.stats.lock().remove_worker(dead_count);
        }
        self.add_executor();
    }
fn parked_executor ( & self , id : usize ) { // protect ourself from re-entry let _guard = self . barrier . lock ( ) ; // dump state of all workers self . workers . read ( ) . iter ( ) . for_each ( | ( _ , v ) | { let state = v . get_state ( ) ; log :: debug ! ( " " v id state ) } ) ; if let Some ( worker ) = self . workers . read ( ) . get ( & id ) { // at this point the worker thread won't load tasks into local queue, so drain it let mut count = 0 ; loop { match worker . stealer . steal ( ) { deque :: Steal :: Empty => break , deque :: Steal :: Retry => ( ) , deque :: Steal :: Success ( task ) => { count += 1 ; self . run_queue . push ( task ) } , } } log :: debug ! ( " " count self run_queue is_empty ( ) ) ; } if let Some ( worker ) = self . workers . write ( ) . remove ( & id ) { // the executor will self-terminate // save the worker, otherwise it gets dropped things go wrong with join self . parked_workers . write ( ) . insert ( id , worker ) ; let dead_count = self . parked_workers . read ( ) . len ( ) ; self . stats . lock ( ) . remove_worker ( dead_count ) ; } self . add_executor ( ) ; }
notification that an executor is parked
notification that an executor is parked
&self
id
usize