Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Neo-Zhixing committed Jun 23, 2023
1 parent 39e3d9d commit cf04a18
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "aftermath"
name = "aftermath-rs"
version = "0.1.0"
edition = "2021"

Expand Down
12 changes: 12 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ impl Drop for Aftermath {
}
}

#[derive(Debug, PartialEq, Eq)]
pub enum Status {
NotStarted = 0,
CollectingData,
Expand All @@ -73,6 +74,17 @@ impl Status {
std::mem::transmute(status)
}
}
pub fn wait_for_status(timeout: Option<std::time::Duration>) -> Self {
let mut status = Self::get();
let delta = std::time::Duration::from_millis(50);
let mut time = std::time::Duration::new(0, 0);
while status != Status::CollectingDataFailed && status != Status::Finished && timeout.map_or(true, |t| time < t) {
std::thread::sleep(delta);
time += delta;
status = Self::get();
}
status
}
}

pub trait AftermathDelegate: Send + Sync + 'static {
Expand Down

0 comments on commit cf04a18

Please sign in to comment.