fn run(&mut self) {
        log::info!("running schdeuler");
        let mut stats_timer = SimpleEventTimer::default();
        let start = Instant::now();
        let mut stats = SchedStats::default();
        while self.is_running {
            // event check
            if stats_timer.check() && self.monitor.send(MonitorMessage::SchedStats(stats)).is_err() {
                log::debug!("failed to send sched stats to mointor");
            }
            // wait for something to do
            match self.receiver.recv_timeout(stats_timer.remaining()) {
                Ok(cmd) => self.maintenance(cmd, &mut stats),
                Err(RecvTimeoutError::Timeout) => (),
                Err(RecvTimeoutError::Disconnected) => self.is_running = false,
            }
        }
        stats.total_time = start.elapsed();
        log::info!("machines remaining: {}", self.machines.len());
        // Dump the machine info
        for (_, m) in self.machines.iter() {
            log::info!(
                "machine={} key={} state={:#?} q_len={} task_id={} disconnected={}",
                m.get_id(),
                m.get_key(),
                m.get_state(),
                m.channel_len(),
                m.get_task_id(),
                m.is_disconnected()
            );
        }
        log::info!("{:#?}", stats);
        log::info!("completed running schdeuler");
    }
// This is the top layer, where machines are added or removed.
// it calls the build select layer.
This is the top layer, where machines are added or removed.
it calls the build select layer.
This is the top layer where machines are added or removed . it calls the build select layer .
fn run(&mut self) {
        log::info!("running schdeuler");
        let mut stats_timer = SimpleEventTimer::default();
        let start = Instant::now();
        let mut stats = SchedStats::default();
        while self.is_running {
            // event check
            if stats_timer.check() && self.monitor.send(MonitorMessage::SchedStats(stats)).is_err() {
                log::debug!("failed to send sched stats to mointor");
            }
            // wait for something to do
            match self.receiver.recv_timeout(stats_timer.remaining()) {
                Ok(cmd) => self.maintenance(cmd, &mut stats),
                Err(RecvTimeoutError::Timeout) => (),
                Err(RecvTimeoutError::Disconnected) => self.is_running = false,
            }
        }
        stats.total_time = start.elapsed();
        log::info!("machines remaining: {}", self.machines.len());
        // Dump the machine info
        for (_, m) in self.machines.iter() {
            log::info!(
                "machine={} key={} state={:#?} q_len={} task_id={} disconnected={}",
                m.get_id(),
                m.get_key(),
                m.get_state(),
                m.channel_len(),
                m.get_task_id(),
                m.is_disconnected()
            );
        }
        log::info!("{:#?}", stats);
        log::info!("completed running schdeuler");
    }
fn run ( & mut self ) { log :: info ! ( " " ) ; let mut stats_timer = SimpleEventTimer :: default ( ) ; let start = Instant :: now ( ) ; let mut stats = SchedStats :: default ( ) ; while self . is_running { // event check if stats_timer . check ( ) && self . monitor . send ( MonitorMessage :: SchedStats ( stats ) ) . is_err ( ) { log :: debug ! ( " " ) ; } // wait for something to do match self . receiver . recv_timeout ( stats_timer . remaining ( ) ) { Ok ( cmd ) => self . maintenance ( cmd , & mut stats ) , Err ( RecvTimeoutError :: Timeout ) => ( ) , Err ( RecvTimeoutError :: Disconnected ) => self . is_running = false , } } stats . total_time = start . elapsed ( ) ; log :: info ! ( " " self machines len ( ) ) ; // Dump the machine info for ( _ , m ) in self . machines . iter ( ) { log :: info ! ( " " m get_id ( ) m get_key ( ) m get_state ( ) m channel_len ( ) m get_task_id ( ) m is_disconnected ( ) ) ; } log :: info ! ( " " stats ) ; log :: info ! ( " " ) ; }
This is the top layer, where machines are added or removed.
This is the top layer where machines are added or removed .
&mut self