in test-fixture/src/sim/mod.rs [205:252]
fn process_loop(&mut self, start: Instant, mut now: Instant) -> Instant {
let mut dgram = None;
loop {
for n in &mut self.nodes {
if dgram.is_none() && !n.ready(now) {
qdebug!("[{}] kipping {:?}", self.name, n.node);
continue;
}
qdebug!("[{}] processing {:?}", self.name, n.node);
let res = n.process(dgram.take(), now);
n.state = match res {
Output::Datagram(d) => {
qtrace!("[{}] => datagram {}", self.name, d.len());
dgram = Some(d);
Active
}
Output::Callback(delay) => {
qtrace!("[{}] => callback {delay:?}", self.name);
assert_ne!(delay, Duration::new(0, 0));
Waiting(now + delay)
}
Output::None => {
qtrace!("[{}] => nothing", self.name);
assert!(n.done(), "nodes should be done when they go idle");
Idle
}
};
}
if self.nodes.iter().all(|n| n.done()) {
return now;
}
if dgram.is_none() {
let next = self.next_time(now);
if next > now {
qinfo!(
"[{}] advancing time by {:?} to {:?}",
self.name,
next - now,
next - start
);
now = next;
}
}
}
}