Skip to content

Commit

Permalink
More informative logs (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
slinkydeveloper authored Dec 13, 2024
1 parent 3c342c4 commit 0a45d53
Show file tree
Hide file tree
Showing 6 changed files with 137 additions and 40 deletions.
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

0 comments on commit 0a45d53

Please sign in to comment.