fn step(&mut self) -> anyhow::Result<bool> {
        debug!("Running next step");

        debug!("Polling fibers");
        // do we have something new from fibers?
        for fiber in &mut self.fibers {
            let reply = fiber.poll();
            debug!("Polling fiber {:?}: {:?}", fiber.kind(), &reply);
            match reply {
                FiberReply::LiveScore { score } => {
                    if fiber.kind() == JudgeLogKind::Contestant {
                        debug!("Step done: sending live score");
                        let live_score = ValuerResponse::LiveScore { score };
                        self.driver
                            .send_command(&live_score)
                            .context("failed to send new live score")?;
                        return Ok(true);
                    } else {
                        debug!("Ignoring live score: kind mismatch");
                    }
                }
                FiberReply::Test { test_id } => {
                    let is_live = self.fibers.iter().any(|fib| fib.test_is_live(test_id));
                    debug!(
                        "Step done: test execution requested (test id {}, live: {})",
                        test_id, is_live
                    );
                    self.send_run_on_test_query(test_id, is_live)?;
                    return Ok(true);
                }
                FiberReply::Finish(judge_log) => {
                    debug!("Step done: new judge log {:?} emitted", judge_log.kind);
                    let resp = ValuerResponse::JudgeLog(judge_log);
                    self.running_fibers -= 1;
                    self.driver
                        .send_command(&resp)
                        .context("failed to submit judge log")?;
                    return Ok(true);
                }
                FiberReply::None => {
                    debug!("No updates from this fiber");
                    continue;
                }
            }
        }
        // do we have pending notifications?
        if let Some(notification) = self
            .driver
            .poll_notification()
            .context("failed to poll for notification")?
        {
            debug!("Step done: got notification");
            self.process_notification(notification);
            return Ok(true);
        }

        // do we have running tests?
        if self.running_tests != 0 {
            debug!("Step done: waiting for running tests completion");
            return Ok(true);
        }
        if self.running_fibers != 0 {
            debug!("Step done: waiting for running fibers completion");
            return Ok(true);
        }

        Ok(false)
    }
/// Executes one iteration.
/// Returns false when valuing finishes.
Executes one iteration.
Returns false when valuing finishes.
Executes one iteration . Returns false when valuing finishes .
fn step(&mut self) -> anyhow::Result<bool> {
        debug!("Running next step");
        debug!("Polling fibers");
        // do we have something new from fibers?
        for fiber in &mut self.fibers {
            let reply = fiber.poll();
            debug!("Polling fiber {:?}: {:?}", fiber.kind(), &reply);
            match reply {
                FiberReply::LiveScore { score } => {
                    if fiber.kind() == JudgeLogKind::Contestant {
                        debug!("Step done: sending live score");
                        let live_score = ValuerResponse::LiveScore { score };
                        self.driver
                            .send_command(&live_score)
                            .context("failed to send new live score")?;
                        return Ok(true);
                    } else {
                        debug!("Ignoring live score: kind mismatch");
                    }
                }
                FiberReply::Test { test_id } => {
                    let is_live = self.fibers.iter().any(|fib| fib.test_is_live(test_id));
                    debug!(
                        "Step done: test execution requested (test id {}, live: {})",
                        test_id, is_live
                    );
                    self.send_run_on_test_query(test_id, is_live)?;
                    return Ok(true);
                }
                FiberReply::Finish(judge_log) => {
                    debug!("Step done: new judge log {:?} emitted", judge_log.kind);
                    let resp = ValuerResponse::JudgeLog(judge_log);
                    self.running_fibers -= 1;
                    self.driver
                        .send_command(&resp)
                        .context("failed to submit judge log")?;
                    return Ok(true);
                }
                FiberReply::None => {
                    debug!("No updates from this fiber");
                    continue;
                }
            }
        }
        // do we have pending notifications?
        if let Some(notification) = self
            .driver
            .poll_notification()
            .context("failed to poll for notification")?
        {
            debug!("Step done: got notification");
            self.process_notification(notification);
            return Ok(true);
        }
        // do we have running tests?
        if self.running_tests != 0 {
            debug!("Step done: waiting for running tests completion");
            return Ok(true);
        }
        if self.running_fibers != 0 {
            debug!("Step done: waiting for running fibers completion");
            return Ok(true);
        }
        Ok(false)
    }
fn step ( & mut self ) -> anyhow :: Result < bool > { debug ! ( " " ) ; debug ! ( " " ) ; // do we have something new from fibers? for fiber in & mut self . fibers { let reply = fiber . poll ( ) ; debug ! ( " " fiber kind ( ) reply ) ; match reply { FiberReply :: LiveScore { score } => { if fiber . kind ( ) == JudgeLogKind :: Contestant { debug ! ( " " ) ; let live_score = ValuerResponse :: LiveScore { score } ; self . driver . send_command ( & live_score ) . context ( " " ) ? ; return Ok ( true ) ; } else { debug ! ( " " ) ; } } FiberReply :: Test { test_id } => { let is_live = self . fibers . iter ( ) . any ( | fib | fib . test_is_live ( test_id ) ) ; debug ! ( " " test_id is_live ) ; self . send_run_on_test_query ( test_id , is_live ) ? ; return Ok ( true ) ; } FiberReply :: Finish ( judge_log ) => { debug ! ( " " judge_log kind ) ; let resp = ValuerResponse :: JudgeLog ( judge_log ) ; self . running_fibers -= 1 ; self . driver . send_command ( & resp ) . context ( " " ) ? ; return Ok ( true ) ; } FiberReply :: None => { debug ! ( " " ) ; continue ; } } } // do we have pending notifications? if let Some ( notification ) = self . driver . poll_notification ( ) . context ( " " ) ? { debug ! ( " " ) ; self . process_notification ( notification ) ; return Ok ( true ) ; } // do we have running tests? if self . running_tests != 0 { debug ! ( " " ) ; return Ok ( true ) ; } if self . running_fibers != 0 { debug ! ( " " ) ; return Ok ( true ) ; } Ok ( false ) }
Executes one iteration.
Executes one iteration .
&mut self