Skip to content
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
4 changes: 3 additions & 1 deletion library/std/src/sys/thread/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ cfg_select! {
}
target_os = "vexos" => {
mod vexos;
pub use vexos::{sleep, yield_now};
pub use vexos::{sleep, sleep_until, yield_now};
#[expect(dead_code)]
mod unsupported;
pub use unsupported::{Thread, available_parallelism, current_os_id, set_name, DEFAULT_MIN_STACK_SIZE};
Expand Down Expand Up @@ -135,6 +135,8 @@ cfg_select! {
target_os = "vxworks",
target_os = "wasi",
target_vendor = "apple",
target_os = "motor",
target_os = "vexos"
)))]
pub fn sleep_until(deadline: crate::time::Instant) {
use crate::time::Instant;
Expand Down
6 changes: 5 additions & 1 deletion library/std/src/sys/thread/motor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::io;
use crate::num::NonZeroUsize;
use crate::sys::map_motor_error;
use crate::thread::ThreadInit;
use crate::time::Duration;
use crate::time::{Duration, Instant};

pub const DEFAULT_MIN_STACK_SIZE: usize = 1024 * 256;

Expand Down Expand Up @@ -62,3 +62,7 @@ pub fn yield_now() {
pub fn sleep(dur: Duration) {
moto_rt::thread::sleep_until(moto_rt::time::Instant::now() + dur)
}

pub fn sleep_until(deadline: Instant) {
moto_rt::thread::sleep_until(deadline.into_inner())
}
10 changes: 7 additions & 3 deletions library/std/src/sys/thread/vexos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ pub fn sleep(dur: Duration) {
let start = Instant::now();

while start.elapsed() < dur {
unsafe {
vex_sdk::vexTasksRun();
}
yield_now();
}
}

pub fn sleep_until(deadline: Instant) {
while Instant::now() < deadline {
yield_now();
}
}
Loading