use std::{ thread, time }; use super::vm::VirtualMachine; pub(crate) struct VirtualMachineMonitor { refresh_rate: u64, } impl VirtualMachineMonitor { pub(crate) fn new() -> VirtualMachineMonitor { VirtualMachineMonitor { refresh_rate: 500, } } pub(crate) fn start(&mut self, vm: VirtualMachine) { loop { { let vm = (*vm).lock().unwrap(); println!("{}", vm.get_word(4)); if vm.is_halted() { println!("HALTED!"); break; } } thread::sleep(time::Duration::from_millis(self.refresh_rate)); } } }