diff --git a/crates/fj-host/src/evaluator.rs b/crates/fj-host/src/evaluator.rs index 9e1a65fba..eb84b0c15 100644 --- a/crates/fj-host/src/evaluator.rs +++ b/crates/fj-host/src/evaluator.rs @@ -1,6 +1,6 @@ use std::thread; -use crossbeam_channel::{Receiver, Sender}; +use crossbeam_channel::{Receiver, SendError, Sender}; use crate::{Error, Evaluation, Model}; @@ -18,19 +18,29 @@ impl Evaluator { thread::spawn(move || { while let Ok(TriggerEvaluation) = trigger_rx.recv() { + if let Err(SendError(_)) = + event_tx.send(ModelEvent::ChangeDetected) + { + break; + } + let evaluation = match model.evaluate() { Ok(evaluation) => evaluation, Err(err) => { - event_tx - .send(ModelEvent::Error(err)) - .expect("Expected channel to never disconnect"); + if let Err(SendError(_)) = + event_tx.send(ModelEvent::Error(err)) + { + break; + } continue; } }; - event_tx - .send(ModelEvent::Evaluation(evaluation)) - .expect("Expected channel to never disconnect"); + if let Err(SendError(_)) = + event_tx.send(ModelEvent::Evaluation(evaluation)) + { + break; + }; } // The channel is disconnected, which means this instance of @@ -60,6 +70,9 @@ pub struct TriggerEvaluation; /// An event emitted by [`Evaluator`] pub enum ModelEvent { + /// A change in the model has been detected + ChangeDetected, + /// The model has been evaluated Evaluation(Evaluation), diff --git a/crates/fj-viewer/src/status_report.rs b/crates/fj-viewer/src/status_report.rs index b78cf9238..a2055f3ec 100644 --- a/crates/fj-viewer/src/status_report.rs +++ b/crates/fj-viewer/src/status_report.rs @@ -20,7 +20,7 @@ impl StatusReport { pub fn update_status(&mut self, status: &str) { let date = { let date = Local::now(); - format!("{}", date.format("[%H:%M:%S]")) + format!("{}", date.format("[%H:%M:%S.%3f]")) }; let empty_space = " ".repeat(date.chars().count()); diff --git a/crates/fj-window/src/run.rs b/crates/fj-window/src/run.rs index 759a58f22..0e6a73f12 100644 --- a/crates/fj-window/src/run.rs +++ b/crates/fj-window/src/run.rs @@ -69,11 +69,13 @@ pub fn run( }; match event { + ModelEvent::ChangeDetected => { + status.update_status( + "Change in model detected. Compiling...", + ); + } ModelEvent::Evaluation(evaluation) => { - status.update_status(&format!( - "Model compiled successfully in {}!", - evaluation.compile_time - )); + status.update_status("Model compiled. Processing..."); match shape_processor.process(&evaluation.shape) { Ok(shape) => { @@ -95,6 +97,8 @@ pub fn run( } } } + + status.update_status("Model processed."); } ModelEvent::Error(err) => {