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
10 changes: 5 additions & 5 deletions src/timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@ use crate::*;
use anyhow::Result;

/// Set a timer using the runtime that will return a Response after the specified duration.
/// The duration should be a number of seconds.
/// The duration should be a number of milliseconds.
pub fn set_timer(duration: u64, context: Option<Context>) {
match context {
None => {
Request::new()
.target(Address::new("our", ProcessId::new("timer", "sys", "uqbar")))
.ipc(duration.to_le_bytes())
.expects_response(duration + 1)
.expects_response((duration / 1000) + 1)
.send()
.unwrap();
}
Some(context) => {
Request::new()
.target(Address::new("our", ProcessId::new("timer", "sys", "uqbar")))
.ipc(duration.to_le_bytes())
.expects_response(duration + 1)
.expects_response((duration / 1000) + 1)
.context(context)
.send()
.unwrap();
Expand All @@ -26,10 +26,10 @@ pub fn set_timer(duration: u64, context: Option<Context>) {
}

/// Set a timer using the runtime that will return a Response after the specified duration,
/// then wait for that timer to resolve. The duration should be a number of seconds.
/// then wait for that timer to resolve. The duration should be a number of milliseconds.
pub fn set_and_await_timer(duration: u64) -> anyhow::Result<Result<(Address, Message), SendError>> {
Request::new()
.target(Address::new("our", ProcessId::new("timer", "sys", "uqbar")))
.ipc(duration.to_le_bytes())
.send_and_await_response(duration + 1)
.send_and_await_response((duration / 1000) + 1)
}