Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 32 additions & 2 deletions src/streamer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,13 @@ pub trait BaseStreamer {
.collect()
}

fn active_dev_names(&self) -> Vec<String> {
self.active_devs()
.iter()
.map(|dev| dev.tag_name())
.collect()
}

fn compile(&mut self, stop_time: Option<f64>) -> Result<f64, String> {
if !self.got_instructions() {
return Err(format!("Streamer did not get any instructions"))
Expand All @@ -119,7 +126,7 @@ pub trait BaseStreamer {
dev.tag_compile(stop_time)?;
}

Ok(self.total_run_time())
Ok(self.shortest_dev_run_time())
}

fn clear_compile_cache(&mut self) {
Expand Down Expand Up @@ -165,7 +172,7 @@ pub trait BaseStreamer {
Ok(())
}

fn total_run_time(&self) -> f64 {
fn shortest_dev_run_time(&self) -> f64 {
// Sanity checks:
/* @Backend developers: before trying to access compile cache
you should always ensure the streamer actually got some instructions
Expand All @@ -188,6 +195,29 @@ pub trait BaseStreamer {
.unwrap()
}

fn longest_dev_run_time(&self) -> f64 {
// Sanity checks:
/* @Backend developers: before trying to access compile cache
you should always ensure the streamer actually got some instructions
and that compile cache is valid (up-to-date with the current edit cache).
Compile cache typically gets invalid due to users forgetting to re-compile after adding pulses.

Functions `got_instructions()` and `validate_compile_cache()` are meant to be the place
to do these checks gracefully. Other functions typically assume these checks have been done.
They likely still double check but may just panic if the tests fail like in the example below.
*/
if !self.got_instructions() {
panic!("Streamer did not get any instructions")
}
self.validate_compile_cache().unwrap();

self.active_devs()
.iter()
.map(|dev| dev.tag_compiled_stop_time())
.reduce(|longest_so_far, this| f64::max(longest_so_far, this))
.unwrap()
}

fn add_reset_instr(&mut self, reset_time: Option<f64>) -> Result<(), String> {
let reset_time = match reset_time {
Some(reset_time) => {
Expand Down
Loading