Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More informative logs #24

Merged
merged 3 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
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
8 changes: 6 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,12 @@ pub trait VM: Sized {

fn sys_state_clear_all(&mut self) -> VMResult<()>;

fn sys_sleep(&mut self, wake_up_time_since_unix_epoch: Duration)
-> VMResult<AsyncResultHandle>;
/// Note: `now_since_unix_epoch` is only used for debugging purposes
fn sys_sleep(
&mut self,
wake_up_time_since_unix_epoch: Duration,
now_since_unix_epoch: Option<Duration>,
) -> VMResult<AsyncResultHandle>;

fn sys_call(&mut self, target: Target, input: Bytes) -> VMResult<AsyncResultHandle>;

Expand Down
6 changes: 3 additions & 3 deletions src/tests/sleep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fn sleep_suspends() {
.run(|vm| {
vm.sys_input().unwrap();

let h1 = vm.sys_sleep(Duration::from_secs(1)).unwrap();
let h1 = vm.sys_sleep(Duration::from_secs(1), None).unwrap();
vm.notify_await_point(h1);
let h1_result = vm.take_async_result(h1);
if let Err(SuspendedOrVMError::Suspended(_)) = &h1_result {
Expand Down Expand Up @@ -67,7 +67,7 @@ fn sleep_completed() {
.run(|vm| {
vm.sys_input().unwrap();

let h1 = vm.sys_sleep(Duration::from_secs(1)).unwrap();
let h1 = vm.sys_sleep(Duration::from_secs(1), None).unwrap();
vm.notify_await_point(h1);
let h1_result = vm.take_async_result(h1);
if let Err(SuspendedOrVMError::Suspended(_)) = &h1_result {
Expand Down Expand Up @@ -115,7 +115,7 @@ fn sleep_still_sleeping() {
.run(|vm| {
vm.sys_input().unwrap();

let h1 = vm.sys_sleep(Duration::from_secs(1)).unwrap();
let h1 = vm.sys_sleep(Duration::from_secs(1), None).unwrap();
vm.notify_await_point(h1);
let h1_result = vm.take_async_result(h1);
if let Err(SuspendedOrVMError::Suspended(_)) = &h1_result {
Expand Down
7 changes: 7 additions & 0 deletions src/vm/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,13 @@ impl RunState {
pub(crate) fn is_running(&self) -> bool {
matches!(self, RunState::Running(_))
}

pub(crate) fn name(&self) -> Option<&str> {
match self {
RunState::Running(n) => Some(n),
RunState::NotRunning => None,
}
}
}

pub(crate) enum EagerGetState {
Expand Down
Loading